Solved

main exception

Posted on 2002-04-10
4
196 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
  • 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: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

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

Title # Comments Views Activity
factorial example 4 47
servlet filter example 37 71
SHA2 certs for IIS AND Java? 2 113
How to configure empty element in XML Document parser? 15 36
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…

839 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