LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   How to compile and run a java program in linux !!!! (https://www.linuxquestions.org/questions/programming-9/how-to-compile-and-run-a-java-program-in-linux-171401/)

jmax24 04-17-2004 04:21 PM

How to compile and run a java program in linux !!!!
 
I have just started programming java using my linux machine. I am running redhat 8 and am wondering if there is anything special i have to get in order to compile and run my jave programs. I was under the impression i could use gcc, so i tried gcc Hello.java and all i got was errors. Any help here would be greatly appreciated.

thx,

jmax24

megaspaz 04-17-2004 04:26 PM

it's not gcc that you want to use. try the gcj3 command. i think that's the one you want, but i don't use it so i don't know.

darin3200 04-17-2004 04:28 PM

gcc is gnu C compiler, it compiles C, not java. You need to go here and get the SDK (software development kit)

jmax24 04-17-2004 05:28 PM

thx darin3200, i did that and it works fine now.

prkherath 03-20-2006 12:09 AM

I want too share two files between two machines. Im runnig Fedora. Plese instruct me how to do so.

paulsm4 03-20-2006 01:22 AM

For whatever it's worth, I'd consider loading Sun's Java Development Kit (JDK):
http://java.sun.com

If you prefer gjc, great. If you're new enough that don't know the difference between Sun Java and gjc - then you're really better off learning Java from the Sun JDK.

IMHO ...

PS:
And if you followed darin3200's advice and got Netbeans ... then please spend at least a little time outside of the IDE, familiarizing yourself with the "javac", "javadoc" and "java" command lines. You'll be much happier - and much more productive in the IDE - as a consequence! Honest!

aher.praju@yahoo.com 08-06-2010 03:45 AM

Hello,

As Java having its own slogan “Create once and run everywhere” , means its totally platform independent so jst adding the JVM(Java Virtual Machine) on Linux, you can execute the java applications on linux.

As I consider you already installed the jdk on your linux server in the directory /usr/local/jdk

Lets test.java be our java application and be sure, now pwd having the /usr/local/jdk path

Now start the execution:

root@localhost:/usr/local/jdk#javac test.java

By javac ,compilation of your application be done and class file of name test.class be created(test.class is in the byte code format)

root@localhost:/usr/local/jdk#java test

And here is the execution of your application,now you can see the output of your application.

**For More details Please refer http://topukhosting.co.uk/Brew-your-...ation-on-Linux..

Sergei Steshenko 08-06-2010 03:56 AM

Quote:

Originally Posted by prkherath (Post 2158904)
I want too share two files between two machines. Im runnig Fedora. Plese instruct me how to do so.

What does it have to do with the thread ?


All times are GMT -5. The time now is 04:35 AM.