LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   compiling a java file to be executable (https://www.linuxquestions.org/questions/programming-9/compiling-a-java-file-to-be-executable-86432/)

spyghost 08-27-2003 08:23 PM

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?

UltimaGuy 08-27-2003 10:10 PM

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.

Robert0380 08-28-2003 01:21 AM

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).

nephilim 08-28-2003 01:26 AM

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.

Viro 08-28-2003 05:00 AM

A jar file doesn't behave like an executable either. You'll still need to type java -jar filename .jar

spyghost 08-28-2003 07:20 AM

Quote:

Originally posted by nephilim
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.
how is that?


All times are GMT -5. The time now is 08:36 PM.