Solved

main exception

Posted on 2002-04-10
4
190 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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
eclipse package explorer vs project explorer view 2 133
mockito example issue 8 72
netstat -ano | find "8000" and taskkill /f /pid 2984 3 57
ejb on wildfly 5 20
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
This video teaches viewers about errors in exception handling.

809 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