• Post Reply Bookmark Topic Watch Topic
  • New Topic

New Learner in Java  RSS feed

 
Zakir Hossain
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have installed jdk1.4 and also made the path in both user and system vairalbles of windows xp sp2 but still i have having nproblem in making java file run, first i compiled it and it comile then when i am making java file run by giving java <filename> then this problem is coming.

Exception in thread " main" java.lang.NoClassDefFoundError : <filename>

tell me what i will do
 
Sam Codean
Ranch Hand
Posts: 194
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Compile all the files. Create the directory structure as the package names you have given. Place all the Class files in the directory structure and then go to the base directory. Run using java [package names (dot separated)].<Main Class Name>

Ex:
Say you have three file in the package 'xyz' called a.java, b.java and c.java
complile all the files and then place the class files in the folder called 'xyz'.

Structure
xyz
a.class
b.class
c.class
Now if a is your main class at root> type
root> java xyz.a

Hope that it helps
 
Layne Lund
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you please show us how you compile and run your program? I assume that you are using the command-line. What command do you type? Also where are your .java files saved? What is the directory structure? Are you trying to use packages at all? Please provide these details so we can help solve your problem.

Layne
 
Zakir Hossain
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
well, my .java is store in bin directory and it is placed in C:\jdk1.4\bin
 
Pradeep Sivadasan
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Zakir,
Before the execution the JVM should know where exactly the class file is existing. The compilation is not a problem. So to execute the compiled file which is in the bin u have to give C:\JDK..\bin> set CLASSPATH=%CLASSPATH%;.; which is nothing but pointing the JVM that the class exist in the bin. then execute..it works
regards,
Pradeep
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!