LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 11-09-2003, 05:18 PM   #1
nejiron
LQ Newbie
 
Registered: Nov 2003
Posts: 10

Rep: Reputation: 0
Having trouble compiling/running java on linux


I installed all the sdk's and what not, but I am still having trouble running my java programs on linux.

I get the error

Exception in thread "main" java.lang.NoClassDefFoundError: MyOS

on all my files, MyOS being the name of the class where main is located.

It works on my windows machine, or if I use telnet to connect to a unix server to run it.

If anyone has any idea what may be wrong I would appreciate the help.

thanks
 
Old 11-09-2003, 06:16 PM   #2
hw-tph
Senior Member
 
Registered: Sep 2003
Location: Sweden
Distribution: Debian
Posts: 3,032

Rep: Reputation: 57
You might have conflicting packages installed. I have had a lot of problems running Sun java (j2se javac and java) when I had gcj installed. If that's the case you should note some non-Sun java classes mentioned in the error message.

Håkan
 
Old 11-09-2003, 06:48 PM   #3
MiscGeek
Member
 
Registered: Jan 2003
Location: Georgia, US
Distribution: RHEL WS4
Posts: 189

Rep: Reputation: 30
Yep, I've ran into the same thing with gcj and Sun's JDK. The only way I've found to completely solve the problem is to remove gcj.
 
Old 11-09-2003, 07:55 PM   #4
nejiron
LQ Newbie
 
Registered: Nov 2003
Posts: 10

Original Poster
Rep: Reputation: 0
How do I check if gjk is installed, I don't remember adding it, so I don't think it is.

I know that Suns sdk is though.

Also, how would I remove it if it is installed.

thanks
 
Old 11-09-2003, 08:26 PM   #5
MiscGeek
Member
 
Registered: Jan 2003
Location: Georgia, US
Distribution: RHEL WS4
Posts: 189

Rep: Reputation: 30
If you have a rpm based distro you should be able to run rpm -q gcj. If it's installed you can remove it by running rpm -e gcj.
 
Old 11-09-2003, 08:41 PM   #6
nejiron
LQ Newbie
 
Registered: Nov 2003
Posts: 10

Original Poster
Rep: Reputation: 0
nope, its not installed

i have j2re installed along with the j2sdk

does that matter?
 
Old 11-10-2003, 12:42 PM   #7
nejiron
LQ Newbie
 
Registered: Nov 2003
Posts: 10

Original Poster
Rep: Reputation: 0
anyone have any other suggestions

when I do echo $PATH
this is what I get:

/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/user/java/j2sdk1.4.2_02/bin:/home/joe/bin:/usr/java/j2sdk1.4.2_02/bin
 
Old 11-10-2003, 02:15 PM   #8
hw-tph
Senior Member
 
Registered: Sep 2003
Location: Sweden
Distribution: Debian
Posts: 3,032

Rep: Reputation: 57
It would be helpful if you could provide the full error message...

Håkan
 
Old 11-10-2003, 02:21 PM   #9
nejiron
LQ Newbie
 
Registered: Nov 2003
Posts: 10

Original Poster
Rep: Reputation: 0
this is the full error:

Exception in thread "main" java.lang.NoClassDefFoundError: (name of class goes here)
 
Old 11-10-2003, 08:48 PM   #10
MiscGeek
Member
 
Registered: Jan 2003
Location: Georgia, US
Distribution: RHEL WS4
Posts: 189

Rep: Reputation: 30
Hmm.., okay what is your classpath set to? Because, that's the only other thing that I can think of. Somehow it's not finding your class.
 
Old 11-10-2003, 10:53 PM   #11
nejiron
LQ Newbie
 
Registered: Nov 2003
Posts: 10

Original Poster
Rep: Reputation: 0
/usr/java/j2sdk1.4.2_02/lib

is the classpath
 
Old 11-10-2003, 11:22 PM   #12
MiscGeek
Member
 
Registered: Jan 2003
Location: Georgia, US
Distribution: RHEL WS4
Posts: 189

Rep: Reputation: 30
Okay, that is probably your problem. You need to include the directory or jar file that contains the class you are trying to run.

i.e java -cp ~/java/<DirName> MyClass
 
Old 11-11-2003, 12:38 AM   #13
nejiron
LQ Newbie
 
Registered: Nov 2003
Posts: 10

Original Poster
Rep: Reputation: 0
thank you so much, finally got it to work

all i had to add was the -cp ./
 
  


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
Trouble Compiling Linux Module damonkohler Linux - Software 9 03-05-2006 01:52 PM
compiling & running java using gcc kiran_kondru17 Linux - Newbie 1 01-04-2005 11:49 AM
running/compiling homemade .java applications truthe Linux - Software 2 10-11-2004 09:12 PM
Having trouble getting java to work on Linux... nejiron Linux - Software 5 11-07-2003 02:58 PM
Compiling Java under Linux nodger Programming 3 10-25-2003 11:15 AM


All times are GMT -5. The time now is 06:43 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