After uninstalling everything on my computer that had the word Java in it, and re-installing the latest Java JRE+SDK, I was able to install Netbeans without a hitch. Sweet victory.
And later, this.
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.
C:\Documents and Settings\%USER%>java -jar "C:\Documents and Settings\%USER%\M
y Documents\NetBeansProjects\Summervale Resort\dist\Summervale_Resort.jar"
Exception in thread "main" java.lang.NoClassDefFoundError: summervaleresort/java
Caused by: java.lang.ClassNotFoundException: summervaleresort.java
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
Could not find the main class: summervaleresort.java. Program will exit.
And in a newly created package to fix this I got a new error.
C:\Documents and Settings\%USER%>java -jar "C:\Documents and Settings\%USER%\M
y Documents\NetBeansProjects\JavaApplication2\dist\JavaApplication2.jar"
Exception in thread "main" java.lang.NoSuchMethodError: main
And yet here is another post. After getting Netbeans up and running, I wrote my programming assignment and hit the same wall I had hit before(last time I used it). I have spent many google searches on this to absolutely no avail, so hopefully this will help someone else. Okay, here was the problem. Every time I tried to run the code after a successful build I hit a
"No main classes found"
message or the weirder errors when trying to run from command prompt.
In the end, however; I found a thread with someone else with the same issue, and no, he never found it out as far as the forum went. Here was the problem. It seems that some people don't want .java files imported into their .jars for some reason, so the default behavior for Netbeans IDE 6.7.1 in all of its wisdom is to ignore both .java and .form files. So, if you happen to write your main code in a .java file, the program will never load it, and therefore no main class will exist.
SOLUTION:
Right click the package and click properties
Expand the build option and click on packaging.
There is a line that says "Exclude from Jar file" with a textbox beside it.
Clear it. Tada! Done.
If that isn't it/you aren't using .java files, make sure that in the run option (in the same area as the build option) that your class is indeed the main class listed there.
That's all for now. Hope that helped.
No comments:
Post a Comment