LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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.

Notices

Reply
 
Search this Thread
Old 03-24-2003, 12:54 PM   #1
JIV
Member
 
Registered: Feb 2003
Location: India
Distribution: RedHat 9.0
Posts: 90

Rep: Reputation: 15
can't run java class files in linux


i'm a newbie to Java and also to Linux
i can't run compiled java programs in Linux
'm using Mandrake Linux 9.0
the error is as follows
java.lang.ClassNotFoundException : JabberWock/class
at java.lang.Class.forName(Class.java:native)
at java.lang.Class.forName(Class.java:59)


I set the path for jdk
Now the error is
Exception in thread "main" java.lang.NoClassDefFoundError : JabberWock/class
this is exactly the same error i got in WindowsXP!!!
please help

Last edited by JIV; 03-24-2003 at 01:12 PM.
 
Old 03-24-2003, 01:25 PM   #2
Hangdog42
LQ Veteran
 
Registered: Feb 2003
Location: Maryland
Distribution: Slackware
Posts: 7,791
Blog Entries: 1

Rep: Reputation: 414Reputation: 414Reputation: 414Reputation: 414Reputation: 414
You either need to set the CLASSPATH environement variable to include the directory that has JaberWock.class or you need to use the -classpath flag when you run the program...

java -classpath /directory/path/JabberWock.class

Setting your PATH to inlcude the j2sdk/bin directory is not sufficient.
 
Old 03-24-2003, 02:00 PM   #3
JIV
Member
 
Registered: Feb 2003
Location: India
Distribution: RedHat 9.0
Posts: 90

Original Poster
Rep: Reputation: 15
i tried java -classpath "\mnt\G\Developers\j2SDK1\MyCodes" Jabberwock.class
but same error .....
Exception in thread "main" java.lang.NoClassDefFoundError
" I also tried this code in Windows platform in my computer and there also same error ....but i can run this on a computer in my Lab"
 
Old 03-24-2003, 02:58 PM   #4
acid2000
Member
 
Registered: Nov 2001
Location: Exeter, UK
Distribution: Gentoo 1.4
Posts: 243

Rep: Reputation: 30
What version of java are you using, the newest version is a bit broken.
 
Old 03-24-2003, 06:45 PM   #5
Hangdog42
LQ Veteran
 
Registered: Feb 2003
Location: Maryland
Distribution: Slackware
Posts: 7,791
Blog Entries: 1

Rep: Reputation: 414Reputation: 414Reputation: 414Reputation: 414Reputation: 414
A couple of possible nitpicky things:

For Linux the path slash is / not \ (that is the DOS way). So if you did enter \mnt\G\... Linux isn't going to recognize it as a valid path. The quotes may also be confusing it.

If you are trying to run JaberWock.class and are in the same directory as JaberWock.class you might try this:

java -cp . JaberWock.class

If you need to add more paths to pick up other classes you could try

java -cp .:/path/class:path/anotherclass JaberWock.class

The fact that you are having the same problem in both Linux and XP suggests it is a classpath problem. You just aren't specifiying where things are correctly. As an additional resource for Java issues (and LOTS of examples) try this website
 
Old 03-24-2003, 08:58 PM   #6
JIV
Member
 
Registered: Feb 2003
Location: India
Distribution: RedHat 9.0
Posts: 90

Original Poster
Rep: Reputation: 15
Yeah thanx man ....now itz working
 
Old 03-25-2003, 02:20 AM   #7
GtkUser
Member
 
Registered: Sep 2002
Location: Canada
Distribution: Redhat 9.0
Posts: 637

Rep: Reputation: 30
It all depends on the organization of your code, if you are using packages, than you need to set the classpath, otherwise you shouldn't need it.
 
  


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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Running a Java executable class from another executable class LUB997 Programming 22 07-24-2005 05:57 AM
Compile Java - .class, .java, .jar ? woranl Programming 2 11-09-2004 11:12 PM
Running Java Class Files hackersapien Programming 9 08-07-2003 07:42 AM
How to run java class everyday automatic?? karleong Linux - Newbie 5 07-15-2003 08:51 AM
HELP for Java class path setting in linux sasi Linux - Software 1 12-14-2001 07:43 AM


All times are GMT -5. The time now is 02:30 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration