LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   run java programs from the command line...howto? (https://www.linuxquestions.org/questions/programming-9/run-java-programs-from-the-command-line-howto-153660/)

rmanocha 03-04-2004 09:57 PM

run java programs from the command line...howto?
 
hi guys,
i have written a java program which is basically a port of the famous BSD games fortune.
Whenever i have to run the program i have to do:
java jfortune <filename>
now i was just wondering how i can run this like a normal program(you know the ones which are in /usr/bin) and have it run automatically without having to have the .class file in the same directory and without having to type java.
do you think writing a small shell script to do this would work?
thanks a lot.

aaa 03-05-2004 02:58 PM

In the command-line, you may always have to type 'java'. If you want to use the same program regularly, then you can make a script and put it in /usr/bin:

#contents of script
java jfortune <filename>

In a GUI, you can associate the class files with java

UltimaGuy 03-06-2004 01:33 AM

Or you can use gcj to compile the program into executables :)

Then the'll run faster too ;)

german 03-06-2004 02:50 AM

the hotspot JIT compiler has proven to be faster in cases than native executables, from what I have read... I can't back that up or explain it, but I'm certain I have seen that comment floating around in several places (IE news://comp.java.lang.programmer)

B.


All times are GMT -5. The time now is 05:09 AM.