How do I configure 'javac' and Using Java on Linux
Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
How do I configure 'javac' and Using Java on Linux
I'm a Linux addict and a Java newbie. I just installed JDK/JRE 1.5.0. on Fedora Core 3 Now, how do I configure 'javac' and'java' on Fedora to compile a Java source code? Whenever I try to compile a source code, I get the following message:
"Exception in thread "main" java.lang.NoClassDefFoundError"
What do I need to do to make java(JVM) recognize and compile my source code?
Please, help me, sombody!!
Distribution: Ubuntu, Debian, Various using VMWare
Posts: 2,088
Rep:
Quote:
Originally posted by linux_newbie_gu ur right, iBall, but also u have to point to the java binary executables, java, javac, in the /usr/local/j2sdk.../bin inur bash_profile.
I'm a Linux newbie, so may have just done something stupid preventing it from working. I downloaded the blackdown sdk version 1.4.2 on recommedendation. I then chmod'd the file, unpacked it and ran the binary executable. It is installed in this way in /usr/local/java.
I then found a site recommending I edit PATH in my .bashrc file, another one telling me to change PATH in /etc/profile and here mentioning .bash_profile. Does it make any difference?
The relevant contents of these files are as follows:
Is something here causing a problem? I edited bashrc first, so I may have unwittingly overwritten something. This could also be true for .bash_profile.
As it stands, my bash shell does not recognise any commands beginnging with "java" at all, although "whereis java" gives the correct path. However, "whereis javac" etc. give no path.
I would remove the line that sets your path in .bashrc. This will actually overwrite your existing path each time you open a new shell, so you will be able to run java and javac, but not ls, mv or anything else. When setting the PATH variable, ensure you add $PATH to the end, like this "export PATH=/new/dir:$PATH" so you still have your old path as well as your addition.
I always add things to .bash_profile, but that is more of a personal choice than anything fixed. .bash_profile is read on login, and .bashrc is read each time your open a new shell or xterm. This means that if you add the "export PATH ..." line to .bashrc, the path will keep growing and growing, so eventually it will be "/usr/local/java/bin:/usr/local/java/bin:/usr/local/java/bin:/usr/local/java/bin:/usr/local/java/bin:/bin:/usr/bin:." which you don't want.
.bash_profile and .bashrc each have their own uses, but both are bash configuration files for the individual user. /etc/profile is a global bash config file, so if you want java to be available to ALL users on your system then add the export lines above to /etc/profile. Otherwise, add to .bash_profile.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.