Solved

main exception

Posted on 2002-04-10
4
203 Views
Last Modified: 2010-03-31
hi experts, l'm having a terrible problem. i just downloaded the j2sdk1.4.0 and get it installed in windows me. i had set the path=c:\j2sdk14\bin where i installed the jdk and wrote a simple program to test as follow

public class test
{
        public static void main( String args[] )
        {
                System.out.println("testing");

        }

}

saved as test.java. i ran "javac test.java" and returned no error.then i ran "java test" and return "exception in thread "main" java.lang.NoClassDefFoundError :test". i really do not know what happens. pls help.
0
Comment
Question by:Explorer060599
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 92

Expert Comment

by:objects
ID: 6933188
It happens because your class is not in your classpath.
You need to include the directory that contains your class in you classpath.

eg. if your class file is in c:\javastuff\test.class

then use:

java -classpath c:\javastuff test

or if you are in the same directory as the classpath you can use:

java -classpath . test
0
 
LVL 92

Accepted Solution

by:
objects earned 10 total points
ID: 6933191
Or you can set the classpath environment variable:

eg.

set CLASSPATH=c:\javastuff;%CLASSPATH%

java test
0
 

Author Comment

by:Explorer060599
ID: 6933224
oh..yeah, you are my god. thanksssss so much. dumb me.

0
 
LVL 92

Expert Comment

by:objects
ID: 6933230
No worries, happy to help :-)

http://www.objects.com.au
Brainbench MVP for Java 1
http://www.brainbench.com
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

697 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question