I am using javac
to compile a file called Rengine.jar
.
I tried:
javac –classpath ./REngine.jar
javac –cp ./REngine.jar
javac ./REngine.jar
javac –classpath REngine.jar
And here are the errors that I got:
javac: invalid flag: –classpath
Usage: javac <options> <source files>
use -help for a list of possible options
javac: invalid flag: –cp
Usage: javac <options> <source files>
use -help for a list of possible options
javac: invalid flag: ./REngine.jar
Usage: javac <options> <source files>
use -help for a list of possible options
javac: invalid flag: –classpath
Usage: javac <options> <source files>
use -help for a list of possible options
I am not familiar with Java at all and I could not find an answer to this problem with a Google search. I precise that I am in the good directory and that I am using Mac OSX. My Java version is 1.8.0_20. Any advice would be much appreciated! :)
Firstly, you cannot compile a .jar
file. A .jar
file is a collection of complied .java
files (.class
files). You are however able to run a .jar
file if your manifest file is set up correctly.
The procedure is as follws:
Compile:
javac MyClass.java
the above line creates MyClass.class
Create JAR with manifest file:
jar cfe myJar.jar myClass myClass.class
Run JAR:
java -jar myJar.jar