Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-11-2008, 08:17 AM
Member
 
Join Date: Mar 2008
Posts: 2
fogus is on a distinguished road
Help with "hello world"
After 3 hours I have decided to turn this over to the experts.

The helloworld.java program is:

Code:
public class helloworld { public static void main(String args[]) { System.out.println("hello world"); } }
The result is:
Code:
>java helloworld java.lang.NoClassDefFoundError: helloworld Caused by: java.lang.ClassNotFoundException: helloworld at java.net.URLClassLoader$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClassInternal(Unknown Source) Exception in thread "main" >Exit code: 1
I am using SciTE as an editor, but I get the same result in the command prompt, when I use:
Code:
command.compile.*.java=javac $(FileNameExt) command.build.*.java=javac *.java command.go.*.java=java $(FileName)
I think this has something to do with my "environment variables"; JCreator can run this program just fine.

Here are the relavent environment variables:
System Variables\CLASSPATH:
C:\Program Files\Java\jdk1.6.0_04\src.jar;
C:\Program Files\Java\jdk1.6.0_04\lib\dt.jar;
C:\Program Files\Java\jdk1.6.0_04\lib\tools.jar;
C:\Program Files\Java\jdk1.6.0_04\jre\lib\il8n.jar;
C:\Program Files\Java\jdk1.6.0_04\jre\lib\jaws.jar;
C:\Program Files\Java\jdk1.6.0_04\jre\lib\rt.jar;
C:\Program Files\Java\jdk1.6.0_04\jre\demo\sound\JavaSound.ja r;
C:\Program Files\Java\jdk1.6.0_04\demo\jfc\SwingSet2\SwingSet 2.jar;
C:\Program Files\Java\jdk1.6.0_04\demo\jfc\SwingApplet\SwingA pplet.jar;
C:\Program Files\Java\jdk1.6.0_04\;
C:\Program Files\Java\jdk1.6.0_04\Bin;
C:\Program Files\Java\jdk1.6.0_04\Lib;
(all on one line, of course)

User Variables\PATH:
C:\Program Files\Java\jdk1.6.0_04\bin

However, when I run SciTE pointed at:

Code:
command.compile.*.java=C:\Program Files\Java\jdk1.6.0_04\bin\javac $(FileNameExt) command.build.*.java=C:\Program Files\Java\jdk1.6.0_04\bin\javac *.java command.go.*.java=C:\Program Files\Java\jdk1.6.0_04\bin\java $(FileName)
I get a slightly different message:


Code:
java.lang.NoClassDefFoundError: helloworld Caused by: java.lang.ClassNotFoundException: helloworld at java.net.URLClassLoader$1.run(URLClassLoader.java:200) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:188) at java.lang.ClassLoader.loadClass(ClassLoader.java:306) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276) at java.lang.ClassLoader.loadClass(ClassLoader.java:251) at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319) Exception in thread "main" >Exit code: 1
1. Anyone care to clue me in on why the default installation of JDK does not work with the command prompt?
2. What should my environment variables be?
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 03-11-2008, 01:42 PM
Member
 
Join Date: Feb 2008
Posts: 7
Menre is on a distinguished road
Hi,

I have noticed something wrong in your coding. In your programme you wrote the line below

public static void main(String args[])

It should be written the way below

public static void main(String[] args )

I hope this solves your problem.

Regards,
Menre
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 03-11-2008, 01:54 PM
Member
 
Join Date: Feb 2008
Posts: 7
Menre is on a distinguished road
Hi,

Sorry, that post was meant for another entry. I have previwed your code in JCreator and it works fine. Both code below work.

public static void main(String args[])

or

public static void main(String[] args)

Regards,
Menre
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 03-11-2008, 02:17 PM
Member
 
Join Date: Mar 2008
Posts: 1
neethur is on a distinguished road
I have lost my httpservlet.jar file from my system, can anyone help me by sending one to my id "neethmohan@yahoo.com"
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 03-11-2008, 09:34 PM
Member
 
Join Date: Dec 2007
Posts: 17
Jman is on a distinguished road
Hi Fogus

I think your problem is that you have not yet compiled your code. I say think because you just mention running java helloworld. If I am wrong please forgive me. But here goes anyway. Try the following
1. save the code as helloworld.java
2. cd to the directory you stored the helloworld.java file
3. run javac helloworld.java
4. then run java helloworld
this should work.
Bookmark Post in Technorati
Reply With Quote
  #6 (permalink)  
Old 03-12-2008, 02:03 AM
Member
 
Join Date: Mar 2008
Posts: 2
fogus is on a distinguished road
You know, Jman, I had tried those steps before, but for some reason things just started to work all of a sudden. Perhaps my environment variables just didn't kick in for a while.

Thanks everyone; the issue has been solved.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
failure at Class.forName("oracle.jdbc.driver.OracleDriver"); RonNYC Eclipse 1 03-14-2008 03:51 PM
Hwlp with "Open", "Save", "Save as..." trill New To Java 1 07-31-2007 08:53 AM
Exception in thread "main" java.net.ConnectException: Connection timed out osval Advanced Java 1 07-27-2007 11:59 PM
Error: Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException romina New To Java 1 07-25-2007 11:55 PM
ArrayList: Exception in thread "main" java.lang.NullPointerException susan New To Java 1 07-16-2007 07:32 AM


All times are GMT +3. The time now is 01:28 AM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org