What is the command-line equivalent (Linux) of
gcc -o executable file.c
for a jar file? (Java instead of gcc)
I know it is possible to do because at my school, all that is necessary is writing "mars" (the MIPS simulator) in command-line
To execute a Java JAR file, run the following command, replacing YourJarFile.jar with the filename of your JAR file.
java -jar YourJarFile.jar
EDIT: There is no way to execute a Java JAR like
./YourJarFile.jar
because the Java Runtime Environment must interpret the JAR file, not the operating system's sh.
java and javac. I think gcj might generate executables, though.java command.To compile Foo.java and Bar.java:
javac Foo.java Bar.java
To put the compiled class files in a jar:
jar cvf classes.jar Foo.class Bar.class
Note that if you put your classes in packages, which you should, your class files will be in a sub-directory and you will have to change the jar command accordingly.