LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This 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


Reply
  Search this Thread
Old 02-12-2005, 10:46 AM   #1
akosombo
LQ Newbie
 
Registered: Feb 2005
Location: Connecticut
Distribution: Fedora Core 3
Posts: 2

Rep: Reputation: 0
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!!
 
Old 02-12-2005, 11:31 AM   #2
XavierP
Moderator
 
Registered: Nov 2002
Location: Kent, England
Distribution: Debian Testing
Posts: 19,192
Blog Entries: 4

Rep: Reputation: 475Reputation: 475Reputation: 475Reputation: 475Reputation: 475
When you say you installed it, how did you go about doing this?

Welcome to LQ by the way

And moved: This thread is more suitable in Linux-General and has been moved accordingly to help your thread/question get the exposure it deserves.
 
Old 02-12-2005, 03:49 PM   #3
craven
LQ Newbie
 
Registered: Nov 2003
Posts: 7

Rep: Reputation: 0
Usually this is a classpath problem. Verify all classpath settings are correct or use the -cp flag javac -cp <classpath>
 
Old 02-13-2005, 09:55 PM   #4
IBall
Senior Member
 
Registered: Nov 2003
Location: Perth, Western Australia
Distribution: Ubuntu, Debian, Various using VMWare
Posts: 2,088

Rep: Reputation: 62
Add
Code:
export CLASSPATH=/path/to/java/lib
to your ~/.bash_profile and then log out and back in again.

--Ian
 
Old 02-13-2005, 10:18 PM   #5
linux_newbie_gu
LQ Newbie
 
Registered: Aug 2004
Posts: 15

Rep: Reputation: 0
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.
 
Old 02-14-2005, 01:11 AM   #6
IBall
Senior Member
 
Registered: Nov 2003
Location: Perth, Western Australia
Distribution: Ubuntu, Debian, Various using VMWare
Posts: 2,088

Rep: Reputation: 62
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.
But that is not exactly difficult:
Code:
export JAVA_HOME=/usr/local/java
export PATH=$JAVA_HOME/bin:$PATH
--Ian
 
Old 03-12-2005, 11:54 AM   #7
emo_kid_joe
LQ Newbie
 
Registered: Mar 2005
Distribution: Mandrake 10.1
Posts: 1

Rep: Reputation: 0
I'm also having similar problems.

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:

.bashrc :
Code:
PATH="/usr/local/java/bin:."
export PATH

.bash_profile :
Code:
export JAVA_HOME=/usr/local/java
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=/usr/local/java/lib
(/etc/profile is unchanged).

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.

Thanks for any help,

Joe
 
Old 03-13-2005, 08:26 AM   #8
IBall
Senior Member
 
Registered: Nov 2003
Location: Perth, Western Australia
Distribution: Ubuntu, Debian, Various using VMWare
Posts: 2,088

Rep: Reputation: 62
Quote:
Originally posted by emo_kid_joe
.bashrc :
Code:
PATH="/usr/local/java/bin:."
export PATH

.bash_profile :
Code:
export JAVA_HOME=/usr/local/java
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=/usr/local/java/lib
(/etc/profile is unchanged).

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.

Sorry if this is a touch long winded
--Ian
 
  


Reply


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to make javac (java compiler) available on whole system? tisam Linux - Software 11 02-14-2005 09:11 AM
can't find java or javac with which command in slack 10.1 but j2re is installed dns21 Slackware 2 02-12-2005 07:51 PM
use gcc or javac for java compile? jordanGSU Programming 22 10-15-2004 09:12 AM
Successfully installed blackdown-jdk14; no java/javac coindood *BSD 1 09-27-2004 05:40 PM
Can't compile Java Swing Applet with javac chansky Programming 4 09-23-2002 04:50 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 10:01 PM.

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