Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

package problem

 
jawwad ahmed
Ranch Hand
Posts: 179
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well i am making a simple program
package chatting;
public class Test
{
public static void main(String args[])
{
}
}
where chatting is stored in
c:\chatting\Test.java
and jdk1.3 is installed in
c:\jdk.1.3\bin
i set path like
c:\chatting:>set path=c:\jdk1.3\bin
it compiles well but give the following exception when run.
Exception in thread "main"
java.lang.NoClassDefFoundError: Test (wrong name: cha
Please tell whats wrong.
 
Arun Boraiah
Ranch Hand
Posts: 233
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
one way to run this class be in the c prompt. and give
java chatting.Test
it works.
-regards
 
jawwad ahmed
Ranch Hand
Posts: 179
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
well there is still problem giving following exception
Exception in thread "main" java.lang.NoClassDefFoundError: Test/java
Please tell.
 
Rob Ross
Bartender
Posts: 2205
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The PATH is just so your command shell can locate the java.exe binary.
You need to set your classpath variable.
Try
java -classpath C:\ chatting.Test
note the space between the "C:\" and "chatting.Test"
[ February 18, 2002: Message edited by: Rob Ross ]
 
Bhushan Jawle
Ranch Hand
Posts: 252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Or try running it as "java chatting/Test" from "C:\" if you don't want to set classpath.
It must work.
Regards,
Bhushan
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic