I had a problem with compiling and running a java file in command line where it imports an external jar files. Here is the solution I've found.
Compilation
javac -cp <path to where the source codes resides>;<path to where the jar file resides> Example.java
run
java <path to where the source codes resides>;<path to where the jar file resides> Example <command-line arguments if any>
Note 1: separator ; for windows and : for unix
Note 2: multiple jar files can be used delimited by ;
Note 3: . can be used to specify the current directory
Showing posts with label jar. Show all posts
Showing posts with label jar. Show all posts
Sunday, December 12, 2010
Dealing with external jar files on command prompt
Labels:
class-path
,
command line
,
jar
,
java
,
windows
How to run a jar file with command line arguments
- Open up a command prompt.
- Go to the directory which jar file resides using the command "cd".
- Type the following command to execute jar file with command line arguments.
- java -jar <name of the jar file> <command line argument1> <command line argument2>
Thursday, November 11, 2010
How to add external jar files in eclipse
1. Inside the "package explorer", Right click on the project which needs to add the external jar file and click on "properties".
Subscribe to:
Posts
(
Atom
)


