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 10-30-2007, 07:32 AM
gvi gvi is offline
Member
 
Join Date: Oct 2007
Posts: 6
gvi is on a distinguished road
Very basic question
I am sure you must have come across this problem and I did google for the solution but it dint work

I am doing my school assignment and I try to write a very simple program (just a helloworld to start with)

When I compile with javac no issues. but when I try to run the program(Test) java Test
I get the following error

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

I found that I need to set the classpath variable but I am not sure where or how or what value to set the classpath at.

If any of you gurus can help that would be great . I have a complex xml parsing program in java to write but am stuck at this simple step. I am beginner in java so sorry if this is too simple


Thanks for your time
G
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 10-30-2007, 07:53 AM
Member
 
Join Date: Jun 2007
Location: Colombo, Sri Lanka
Posts: 31
hiranya is on a distinguished road
I'm fairly new to Java too. In my opinion there is no need to setup class paths to run simple Java programs like 'Hello World' applications. It should work fine. However here are some points you can check.

1. Is the name of your class equal to the name of the file? (your file name should be Test.java only if your class name is Test - I think you got this right since your program gets compiled without errors)

2. Check whether a file called Test.class is generated in the same directory once you compile the program.

3. To run the program issue the command 'java Test' (not 'java Test.class')

4. Have you encapsulated your class in a package? (sometimes this can cause problems when trying to run the application)

If you still want to try setting the class path refer the following article from Sun.
Setting the class path

Hope this helps. All the best.

Regards,
Hiranya
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 10-30-2007, 07:30 PM
gvi gvi is offline
Member
 
Join Date: Oct 2007
Posts: 6
gvi is on a distinguished road
Thanks hiranya

Your first suggestion worked. I dont know how it got compiled and my file name and class name were different.

Alteast I got the first step correct. I have a complex program ahead of me now. But thanks much for your time and reply

G
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
Basic Applet jkswebsite Java Applets 4 01-13-2008 10:14 PM
Basic question about EJB javaplus Enterprise JavaBeans 0 12-02-2007 11:00 PM
basic question about files oregon New To Java 1 08-05-2007 03:34 AM
help with basic example fred New To Java 1 07-20-2007 06:45 PM
Question mark colon operator question orchid Advanced Java 3 04-30-2007 11:37 PM


All times are GMT +3. The time now is 12:40 AM.


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