4

I am using Netbeans from many days. But suddenly it started giving me following errors for simple hello programs.

 java.lang.NoClassDefFoundError: newr
 Caused by: java.lang.ClassNotFoundException: newr
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
Exception in thread "main" Java Result: 1 
BUILD SUCCESSFUL (total time: 3 seconds)

here it is

My prog is simple hello program

public class newr {
public static void main(String argv[]){
    System.out.println("hello");
}
}

It happens very very oftentimes with me. I had tried to uninstall and again install it but this doesn't resolve my problem. I also tried to delete .netbeans folder that contain net bean's cache. But i have to delete this .netbeans folder every times it gives me such errors. Is there any way to permanently fix the error? I am tired of deleting the cache and uninstalling netbeans please help me....

adesh
  • 832
  • 4
  • 14
  • 23
  • 1
    You mightalso want to ask this at http://forums.netbeans.org/ – Mchl Feb 10 '12 at 14:03
  • 1
    Might want to post some code of your application, the problem probably isn't your NetBeans installation. – Jean-Philippe Roy Feb 10 '12 at 14:04
  • i have included my program in question please go through it – adesh Feb 10 '12 at 14:07
  • 1
    I am not sure but maybe it is related to this problem: [http://stackoverflow.com/q/5965798/620338](http://stackoverflow.com/q/5965798/620338) and has something to do with the lowercase/uppercase class name (class names should begin with an uppercase letter in java). – Matt Handy Feb 10 '12 at 14:18
  • ya i know class name should beggin with upper case but i was just trying. The error is not case sensitive. – adesh Feb 10 '12 at 14:21
  • 1
    see this link may be helpful to you.. http://stackoverflow.com/questions/3537769/cant-find-main-class-in-netbeans-6-9 – Abhishek Aggarwal Feb 25 '12 at 03:45

2 Answers2

10

Deleting NetBeans's cache worked for me (version 7.2).

Find the cache folder (In help->about), close NetBeans, navigate to the folder, and delete the index folder. Reopen NetBeans, clean and rebuild, and it should find all the classes this time.

user453441
  • 1,026
  • 2
  • 13
  • 26
  • This process worked for me, but is there a way within Netbeans to force this cache clear? I feel like that's a failing on the environment's part if it has to be done manually like this. – Draque Thompson Feb 24 '17 at 15:35
0

Deleting the cache of NetBeans solves the problem. To automate this task, you can manually write a script which would first delete the cache folder and then start NetBeans. You can also make this script executable and use it as the shortcut for starting NetBeans. You can Google the process of making your script executable, depending on your Operating System.