Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

exception error in thread main

Status
Not open for further replies.
Joined
Oct 28, 2003
Messages
3
Location
US
I am able to compile a class : but when I run it get an exception error in thread main java.langNoClassDeffound error mypack

mypack is the directory where I stored the .java file
first line in the file is : package MyPack;

my autoexec.bat has the following: classpath set
PATH "c:\j2sdk1.4.2_04\bin";
CLASSPATH .;c:\MyPack

i can compile the class from the mypack directory in which it is located, but when I do a java classname get the above error, when I take out the line : package mypack;
from the java file and recompile and run it , it works fine.

example of program:
package MyPack;
class Test {
public void main(String[]args)
{ System.out.println("Anything")
}
}
thanks for any suggestions:
 
package MyPack;
class Test {
public static void main(String[]args)
{ System.out.println("Anything");
}
}
//Assume you are at root directory c:\ and there is a directory called MyPack and contain the Test.java

At root directory, you can use javac MyPack/Test.java to compile it.
java MyPack/Test to run it
 
prosper has a small typo, you should use

java MyPack.Test

to run it.

--------------------------------------------------
Free Java/J2EE Database Connection Pooling Software
 
stroke or dot is ok in windows.
I don't know dot work. Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top