First up, compiling a Java file from the command line on Windows with multiple jar files.
1. Change directory to wherever your java file is located using the cd command like so:
- >cd path\to\source\folder
2. Once you are in the source folder, use the following command to set the path. This will allow your computer to find the Java commands in the next step.
- >set path=%path%; "path\to\java\bin"
- >set path=%path%; "C:\Program Files\Java\jdk1.7.0_45\bin"
3. With the path set, all that's left is to compile the file! To compile the file, we will use the javac command and set the -classpath parameter to where our .jar files are (in this case, I have a folder of jar files). In order to include all .jar files in the folder, the folder path will end in *.
- >javac -classpath "path\to\jar\folder\*" FileToCompile.java
An example run of this would be:
- >javac -classpath "C:\Users\owner\jars\*" HelloWorld.java
Hope this helps!
No comments:
Post a Comment