Java Java Exception - NoDefClassFoundError

  • Thread starter Thread starter rollcast
  • Start date Start date
  • Tags Tags
    Java
AI Thread Summary
The discussion centers on a user encountering a "NoClassDefFoundError" when trying to run a Java program in Geany. The error indicates that the Java runtime cannot find the main class named "temp." It emphasizes that Java requires precise naming conventions for program files and adherence to directory structures. The user is advised to test a simple "hello world" example from the system documentation to ensure proper setup. Additionally, setting up environment variables, particularly the CLASSPATH, may be necessary for the program to run successfully.
rollcast
Messages
403
Reaction score
0
I'm trying to run a java program I coded using geany but it would let me run it as it comes up with the following error message.

Code:
Exception in thread "main" java.lang.NoClassDefFoundError: temp
Caused by: java.lang.ClassNotFoundException: temp
	at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
Could not find the main class: temp. Program will exit.

So then I thought it may have been my bad coding but even when I copied a few example codes from wikipedia it still gave me the same error?

Thanks
A.
 
Technology news on Phys.org
It looks like you are missing a definition for a class named temp.
 
Java is different from most programming languages in that it is VERY fussy about what you call your program files, and the directory structure you put them in.

There should be a "hello world" type of example in the system documentation. Try that, and make sure you do EXACTLY what it tells you to do.

You might have to set up some environment variables (CLASSPATH, in particular) before anything works.
 
Dear Peeps I have posted a few questions about programing on this sectio of the PF forum. I want to ask you veterans how you folks learn program in assembly and about computer architecture for the x86 family. In addition to finish learning C, I am also reading the book From bits to Gates to C and Beyond. In the book, it uses the mini LC3 assembly language. I also have books on assembly programming and computer architecture. The few famous ones i have are Computer Organization and...
I have a quick questions. I am going through a book on C programming on my own. Afterwards, I plan to go through something call data structures and algorithms on my own also in C. I also need to learn C++, Matlab and for personal interest Haskell. For the two topic of data structures and algorithms, I understand there are standard ones across all programming languages. After learning it through C, what would be the biggest issue when trying to implement the same data...
Back
Top