compiling a java file to be executable
hi,
how can a java files be compiled such that i won't need to type: java <filename> to make it run.... instead: <filename> how is it? |
You can use gcj, the java compiler that comes with gcc, to compile your java source files into binary files. But, the resultant binary file will only be executable in that platform.
|
or you can make a shell script/ batch file that calls it.
i acutally did this just to make it "clickable" in windows (and Linux). for instace: #!/bin/bash /opt/java/bin/java /java_file/RunMe you can save that as like... runme, make it executeable.... chmod u+x runme and then just be like ./runme and to do you one even better...drop runme into /usr/local/bin and make sure /usr/local/bin is in your PATH env. variable and you can just be like runme oh, make sure you get all the path names right too. and the binary will be platform independant (if compiled with a standard java compiler). |
You have to create an executable jar file. In order to be executable, you have to set the classpath and point of entry in the MANIFEST of the jar file.
|
A jar file doesn't behave like an executable either. You'll still need to type java -jar filename .jar
|
Quote:
|
All times are GMT -5. The time now is 08:36 PM. |