Fedora Linux Support Community & Resources Center
  #1  
Old 14th May 2005, 05:28 AM
mbdayton Offline
Registered User
 
Join Date: May 2005
Posts: 25
Java error

I just finished reading a Java for Dummies book and I'm trying to get the Java SDK to work.

Compiling code works just fine, but as soon as I try and run a program I get this:

Exception in thread "main" java.lang.NoClassDefFoundError

I've fiddled with setting the CLASSPATH in bashrc, and I've even tried setting it using -cp and -classpath, but I k eep getting the same error.

Any ideas?

Last edited by mbdayton; 14th May 2005 at 10:59 PM.
Reply With Quote
  #2  
Old 14th May 2005, 11:37 PM
crackers Offline
Retired Community Manager
 
Join Date: Feb 2004
Location: Seattle, WA, USA
Age: 57
Posts: 3,423
Firstly, you don't want to set CLASSPATH and, if you're just beginning, I wouldn't worry about -cp either.

If you can't figure it out from the Dummies book, I'd recommend starting with the Java Tutorial off of http://java.sun.com/docs/index.html

If, after that, you can't figure out what's going wrong, you'll need to post where your .java file(s) are, how you're starting the SDK, and what version of the SDK you're using (java -version).
__________________
Linux User #28251 (April '93)
Professional Java Geek :cool:
Reply With Quote
  #3  
Old 14th May 2005, 11:46 PM
mbdayton Offline
Registered User
 
Join Date: May 2005
Posts: 25
thanks, I'll start with the java tutorial.
Reply With Quote
  #4  
Old 15th May 2005, 12:17 AM
mbdayton Offline
Registered User
 
Join Date: May 2005
Posts: 25
Well I was able to compile and run a program succesfully, but now it only works while I'm logged in as root. What's the deal?

BTW, thanks for moving my post to the right forum. I'm loving this place!
Reply With Quote
  #5  
Old 18th May 2005, 07:51 PM
cybrjackle Offline
Registered User
 
Join Date: Jan 2004
Posts: 456
You probably need to create a file like this:

more /etc/profile.d/java.sh
Code:
export JAVA_HOME="/opt/jdk1.5.0_03"
export JAVA_PATH="$JAVA_HOME"
export PATH="$PATH:$JAVA_HOME/bin"
As far as the original error you recieved, you probably ran into the same problem I did. (learning java too)

Say you created a java file called ForLoop.java and you compiled it and ended up with a ForLoop.class, BUT inside your .java you labeled it

Code:
public class ForLoop
You can simply mv/cp ForLoop.class to ForLoop and it should work. Or I "guess" if you had:

Code:
public class ForLoop.class
It would have worked.

Checkout "Head First Java 2nd Edition" by Kathy Sierra & Bert Bates, good book!
__________________
aka "jlc" on irc.

Main Desktop:
Rawhide x86_64
MSI K8N NEO2 Platinum
AMD Athlon 64 3200+ Winchester @ 2350MHz
CORSAIR XMS TWINX1024-3200C2 2GB
BFG Nvidia GeForce 6800GT OC @ 370MHz 256MB GDDR3
2x80GB SATA 150 Segate Raid 0
Reply With Quote
  #6  
Old 18th May 2005, 11:10 PM
mbdayton Offline
Registered User
 
Join Date: May 2005
Posts: 25
Quote:
You probably need to create a file like this:

more /etc/profile.d/java.sh
So I'm creating a seperate file from my my bashrc file?
If so do I need to reference this file from my profile file?
Reply With Quote
  #7  
Old 18th May 2005, 11:33 PM
Jman Offline
Registered User
 
Join Date: Mar 2004
Location: Minnesota, USA
Age: 28
Posts: 7,909
~/.bashrc should work, but only for your user.
Reply With Quote
  #8  
Old 19th May 2005, 12:32 AM
cybrjackle Offline
Registered User
 
Join Date: Jan 2004
Posts: 456
When you log in, environment variables are set from /etc/profile (for all users).
Then all the files in the /etc/profile.d directory.
Then ~/.bash_profile, then ~/.bashrc.

So either way will work.
__________________
aka "jlc" on irc.

Main Desktop:
Rawhide x86_64
MSI K8N NEO2 Platinum
AMD Athlon 64 3200+ Winchester @ 2350MHz
CORSAIR XMS TWINX1024-3200C2 2GB
BFG Nvidia GeForce 6800GT OC @ 370MHz 256MB GDDR3
2x80GB SATA 150 Segate Raid 0
Reply With Quote
  #9  
Old 19th May 2005, 07:21 AM
Unkemptwolf Offline
Registered User
 
Join Date: Feb 2005
Age: 46
Posts: 60
When you execute the file, are you doing
Code:
java ProgramName.class
because for whatever reason, it freaks out the JVM whn you do that. You should just type
Code:
java ProgramName
without the .class extension. Sorry if this isnt the fix, but I remember having this same problem when I came back to java after a couple of years away.
__________________
System Specs:
Compaq 2195us
Fedora Core 3
  • Athlon XP-M 2500+
  • 512 MB RAM
  • Radeon IGP 320M
  • 40 GB Hard Drive
  • Broadcom 802.11g Wireless
  • ~2.5 Hrs Battery Per Charge
Reply With Quote
  #10  
Old 19th May 2005, 02:58 PM
mbdayton Offline
Registered User
 
Join Date: May 2005
Posts: 25
thanks to everyone for the help. I haven't had the time to work on it for awhile, but I'll report back once I have a chance to try some of this stuff.

This is the first programming I've ever done, so this has been helpful.
Reply With Quote
  #11  
Old 19th May 2005, 03:48 PM
cybrjackle Offline
Registered User
 
Join Date: Jan 2004
Posts: 456
Quote:
Originally Posted by Unkemptwolf
When you execute the file, are you doing
Code:
java ProgramName.class
because for whatever reason, it freaks out the JVM whn you do that. You should just type
Code:
java ProgramName
without the .class extension. Sorry if this isnt the fix, but I remember having this same problem when I came back to java after a couple of years away.
thx for that bit of info, i just kept renaming I"ve been java programming all of 7 days now or atleast learning.
__________________
aka "jlc" on irc.

Main Desktop:
Rawhide x86_64
MSI K8N NEO2 Platinum
AMD Athlon 64 3200+ Winchester @ 2350MHz
CORSAIR XMS TWINX1024-3200C2 2GB
BFG Nvidia GeForce 6800GT OC @ 370MHz 256MB GDDR3
2x80GB SATA 150 Segate Raid 0
Reply With Quote
Reply

Tags
error, java

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
[F9 64-bit] jperf Java f/e for iperf - Java exception error techmum Using Fedora 0 24th July 2008 01:22 AM
help, about a java error NAC Using Fedora 4 29th November 2007 06:42 PM
java error festhead Programming & Packaging 3 6th August 2007 09:15 PM
FC5 Java Error jsin Using Fedora 7 24th April 2006 02:17 AM
which java error thisObject Using Fedora 10 16th April 2006 08:49 PM


Current GMT-time: 18:01 (Thursday, 21-08-2014)

TopSubscribe to XML RSS for all Threads in all ForumsFedoraForumDotOrg Archive
logo

All trademarks, and forum posts in this site are property of their respective owner(s).
FedoraForum.org is privately owned and is not directly sponsored by the Fedora Project or Red Hat, Inc.

Privacy Policy | Term of Use | Posting Guidelines | Archive | Contact Us | Founding Members

Powered by vBulletin® Copyright ©2000 - 2012, vBulletin Solutions, Inc.

FedoraForum is Powered by RedHat