LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
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 09-16-2008, 03:37 AM   #1
efus
Member
 
Registered: Jun 2003
Location: Odense, Denmark
Distribution: Fedora
Posts: 32

Rep: Reputation: 15
java problem


I need to do some java programming, so I installed openJDK.
The code compiles fine, but when I try to run it I get this error:

Code:
Exception in thread "main" java.lang.NoClassDefFoundError: HelloWorld
Caused by: java.lang.ClassNotFoundException: HelloWorld
	at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:323)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:268)
	at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:336)
Could not find the main class: HelloWorld. Program will exit.
I get this error with openjdk and sun jdk?
anyone know how to fix this?
 
Old 09-16-2008, 08:28 AM   #2
harry2006
Member
 
Registered: Aug 2006
Location: /hawaii/honolulu/downtown
Distribution: Fedora 10[Cambridge] and Ubuntu 9.04[Jaunty]
Posts: 201

Rep: Reputation: 30
from the error log it seems u r code is incomplete....some class definiton is missing...have a walk-thur of ur code....must be something missing....if u r stillhaving problem....reply with ur code...lets have a look over ur code..tehn it'll be easy fro nyone so say whats the issue...
was ur installation OK...all jar files added properly to the library...???
 
Old 09-16-2008, 11:04 PM   #3
armanox
Member
 
Registered: Sep 2005
Location: Baltimore, MD, USA
Distribution: Fedora, Gentoo, Debian, Slackware, IRIX, OS X
Posts: 192

Rep: Reputation: 32
Looks like a hello world program. Send me it and I'll look it over - it looks like a problem with the source.
 
Old 09-17-2008, 05:53 AM   #4
efus
Member
 
Registered: Jun 2003
Location: Odense, Denmark
Distribution: Fedora
Posts: 32

Original Poster
Rep: Reputation: 15
I don't think it's the source.
The source looks lige this

Code:
public class HelloWorld {
  public static void main(String[] args) {
    
  }
}
and it still gives the error.
It is only on this system I get the error.
Other java apps run fine so I asume the java installation is ok.
 
Old 09-17-2008, 06:00 AM   #5
elprawn
Member
 
Registered: Feb 2005
Distribution: Gentoo 2008
Posts: 138

Rep: Reputation: 15
Add . to your $CLASSPATH.
 
Old 09-17-2008, 02:56 PM   #6
efus
Member
 
Registered: Jun 2003
Location: Odense, Denmark
Distribution: Fedora
Posts: 32

Original Poster
Rep: Reputation: 15
this is my CLASSPATH

Code:
/usr/lib/jvm/java-1.6.0-openjdk/lib:/usr/lib/jvm/java-1.6.0-openjdk/jre/lib:/usr/lib/jvm/java-1.6.0-openjdk/lib:/usr/lib/jvm/java-1.6.0-openjdk/jre/lib
where sould I put the . ?
 
Old 09-17-2008, 03:53 PM   #7
elprawn
Member
 
Registered: Feb 2005
Distribution: Gentoo 2008
Posts: 138

Rep: Reputation: 15
Code:
usr/lib/jvm/java-1.6.0-openjdk/lib:/usr/lib/jvm/java-1.6.0-openjdk/jre/lib:/usr/lib/jvm/java-1.6.0-openjdk/lib:/usr/lib/jvm/java-1.6.0-openjdk/jre/lib:.
 
Old 09-18-2008, 03:37 AM   #8
efus
Member
 
Registered: Jun 2003
Location: Odense, Denmark
Distribution: Fedora
Posts: 32

Original Poster
Rep: Reputation: 15
Great! It works now. Thank you!
 
Old 09-18-2008, 08:04 AM   #9
peeths003
Member
 
Registered: Jun 2008
Distribution: Fedora 12 i686, Debian 5.0.1 i686, Fedora 14 x86_64, Debian Lenny 5.0.1x86_64 and CentOS_5.4_x86-64
Posts: 311

Rep: Reputation: 32
This is because the JVM was not able to locate your HelloWorld.class file . if you are in the directory of the class file . and you add a . against the classpath , the jvm adds the current directory path and finds your class name .
 
  


Reply



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
java problem wererabit Linux - Newbie 4 11-16-2006 02:41 AM
java problem wererabit Ubuntu 1 11-15-2006 02:22 PM
java problem chidomen Linux - Newbie 3 01-14-2005 08:27 PM
java problem bm1 Linux - Software 0 04-22-2004 03:01 AM
Java Problem bwaynej2002 Linux - Software 4 01-21-2004 06:40 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 03:03 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
Open Source Consulting | Domain Registration