Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 04-17-2004, 05:21 PM   #1
Registered: Apr 2004
Posts: 39

Rep: Reputation: 15
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 and all i got was errors. Any help here would be greatly appreciated.


Old 04-17-2004, 05:26 PM   #2
Senior Member
Registered: Nov 2002
Location: Silly Con Valley
Distribution: Red Hat 7.3, Red Hat 9.0
Posts: 2,054

Rep: Reputation: 46
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.
Old 04-17-2004, 05:28 PM   #3
LQ Guru
Registered: Dec 2002
Distribution: Gentoo!
Posts: 1,153

Rep: Reputation: 45
gcc is gnu C compiler, it compiles C, not java. You need to go here and get the SDK (software development kit)
Old 04-17-2004, 06:28 PM   #4
Registered: Apr 2004
Posts: 39

Original Poster
Rep: Reputation: 15
thx darin3200, i did that and it works fine now.
Old 03-20-2006, 01:09 AM   #5
LQ Newbie
Registered: Jan 2006
Posts: 1

Rep: Reputation: 0
I want too share two files between two machines. Im runnig Fedora. Plese instruct me how to do so.
Old 03-20-2006, 02:22 AM   #6
LQ Guru
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
For whatever it's worth, I'd consider loading Sun's Java Development Kit (JDK):

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

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!

Last edited by paulsm4; 03-20-2006 at 02:25 AM.
Old 08-06-2010, 04:45 AM   #7
LQ Newbie
Registered: Jun 2010
Location: India
Posts: 2
Blog Entries: 4

Rep: Reputation: 0


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 be our java application and be sure, now pwd having the /usr/local/jdk path

Now start the execution:


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

Last edited by; 08-06-2010 at 04:56 AM.
Old 08-06-2010, 04:56 AM   #8
Sergei Steshenko
Senior Member
Registered: May 2005
Posts: 4,481

Rep: Reputation: 454Reputation: 454Reputation: 454Reputation: 454Reputation: 454
Originally Posted by prkherath View Post
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 ?


java, linux

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
how to run linux command from java program? ranger225 Linux - Newbie 1 11-10-2004 07:55 AM
compile and run java pelegk2 Programming 3 10-05-2004 10:28 AM
GIF gone in program when compile Java in Linux dwarf007 Programming 1 10-01-2004 12:15 AM
How to compile and run my first program vanhelsing Programming 2 07-11-2004 03:41 PM
Compile and run java in Linux Redhat medeluckiest Linux - Newbie 1 03-15-2004 10:03 AM > Forums > Non-*NIX Forums > Programming

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

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration