• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

New Learner in Java

 
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 194
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
well, my .java is store in bin directory and it is placed in C:\jdk1.4\bin
 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
reply
    Bookmark Topic Watch Topic
  • New Topic