I am getting the following error when running my program. Compilation works just fine! and the program was working a min ago wht the hell is going on?! can you please help
java.lang.VerifyError: (class: FinalTest, method: <init> signature: ()V) Constructor must call super() or this()
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2442)
at java.lang.Class.getMethod0(Class.java:2685)
at java.lang.Class.getMethod(Class.java:1620)
at sun.launcher.LauncherHelper.getMainMethod(LauncherHelper.java:484)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:476)
Exception in thread "main" Java Result: 1
Javadoc says:
Thrown when the "verifier" detects that a class file, though well
formed, contains some sort of internal inconsistency or security
problem.
As you application was running a mintute ago, it should not be a security issue. Cleanup all your .class files, rebuild your application and run it. Also, check your compilation warnings to make sure you don't have conflicting dependencies.
Just copy the whole project .. and run the new one.. It worked for me.
Related
i exported my java programm to an executable JAR-File.
When i now run this JAR-File:
java -jar myFile.jar
this Exception appears:
Exception in thread "main" java.lang.NullPointerException
at javax.swing.JList$4.getSize(Unknown Source)
at javax.swing.plaf.basic.BasicListUI.updateLayoutState(Unknown Source)
at javax.swing.plaf.basic.BasicListUI.maybeUpdateLayoutState(Unknown Source)
at javax.swing.plaf.basic.BasicListUI.getPreferredSize(Unknown Source)
....
Never saw this before and havent found a solution yet.
What is actually happening here and how can i solve this problem?
It doesn't seems to be a packaging related issue. It looks more like there is a JList not properly initialized - e.g. like if you passed null as the array in the constructor. So check your code...
Procedure:
Expand the jar in exactly the same location as the jar as a directory, say, ExpDir.
Run the main class using -cp ExpDir and main class. Use the same current directory, JVM, and everything else.
If the program now works (1% probability, in my experience), comment on this on the question. Also, confirm that you are not inadvertently changing something else.
If it does not (99% probability), correct the programming error and/or ask a different question appropriate to the error.
I am running my java program but on executing it gives me following error.
before it was running fine but now it's throwing following error.
I checked my class path, path in environment variable all are correct.
Exception in thread "main" java.lang.UnsatisfiedLinkError: java.util.zip.ZipFile
.open(Ljava/lang/String;IJ)J
at java.util.zip.ZipFile.open(Native Method)
at java.util.zip.ZipFile.<init>(ZipFile.java:114)
at java.util.jar.JarFile.<init>(JarFile.java:135)
at java.util.jar.JarFile.<init>(JarFile.java:72)
at sun.misc.URLClassPath$JarLoader.getJarFile(URLClassPath.java:646)
at sun.misc.URLClassPath$JarLoader.access$600(URLClassPath.java:540)
at sun.misc.URLClassPath$JarLoader$1.run(URLClassPath.java:607)
at java.security.AccessController.doPrivileged(Native Method)
at sun.misc.URLClassPath$JarLoader.ensureOpen(URLClassPath.java:599)
at sun.misc.URLClassPath$JarLoader.<init>(URLClassPath.java:583)
at sun.misc.URLClassPath$3.run(URLClassPath.java:333)
at java.security.AccessController.doPrivileged(Native Method)
at sun.misc.URLClassPath.getLoader(URLClassPath.java:322)
at sun.misc.URLClassPath.getLoader(URLClassPath.java:299)
at sun.misc.URLClassPath.getResource(URLClassPath.java:168)
at java.net.URLClassLoader$1.run(URLClassLoader.java:194)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
Could not find the main class: com.sun.tools.javac.Main. Program will exit.
To elaborate on #Peter Lawrey's answer ...
The start of the stacktrace is this:
Exception in thread "main" java.lang.UnsatisfiedLinkError: java.util.zip.ZipFile
.open(Ljava/lang/String;IJ)J
at java.util.zip.ZipFile.open(Native Method)
at java.util.zip.ZipFile.<init>(ZipFile.java:114)
...
The UnsatisfiedLinkError is thrown when you attempt to call a native method that has not been resolved to a method in the corresponding native library. The rest of the message tells us that the method at fault has the signature:
long java.util.zip.ZipFile.open(String, int, long)
and that meshes with the top frame of the stack trace ... and the fact that Java's ZipFile code is known to use a native library for the heavy lifting.
The fact that it has gotten this far means that the JVM has found the native library and loaded it. But apparently, the load didn't resolve this overload of the native open method. That can only mean one thing: that the version of the ZipFile class on the bootclasspath does not match the native library.
We cannot make any definite conclusions about whether this is a JDK or a JRE, but it seems likely that it is a JDK ... unless the OP is trying to call the Java compiler in a strange way. (The "could not find the main class: com.sun.tools.javac.Main" message probably means that the JVM could not load the class ... because of the UnsatisfiedLinkError breakage.)
Either way, JDK versus JRE is not the immediate problem. The real problem is a mismatch between the "rt.jar" on the JVM's bootclasspath, and the native libraries.
The question asks:
how to solve this then?
It depends on what exactly you did to get this error.
What command did you run?
What were the command line options and arguments?
Have you been "messing around" with your JRE / JDK installation?
Are you trying to use the "rt.jar" file from one installation in another one?
It means your rt.jar is for a different version of Java as your JVM.
I would ensure that you don't have a rt.jar in your boot class path and your JRE is installed correctly.
Could not find the main class: com.sun.tools.javac.Main. Program will exit.
When a class fails to load due to some low level error, it reports that the class could not be found.
The reference in the error message about not finding com.sun.tools.javac.Main leads me to believe that this is a program that needs to be run with the JDK rather than just a JRE.
your JRE path is pointing to the JDK path
Solution :
Step 1: Right click the server
Step 2: Click the Run Time Configuration
Step 3: GIVE the JRE path under the JDK.
Solution fixed
I just restarted java for university and I have a pretty basic program that I need to code. The thing is every time I try to run it, I get a NoClassDefFoundError as follow:
run:
java.lang.NoClassDefFoundError: log120/devoir1/LOG120Devoir1
Caused by: java.lang.ClassNotFoundException: log120.devoir1.LOG120Devoir1
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
Could not find the main class: log120.devoir1.LOG120Devoir1. Program will exit.
Exception in thread "main" Java Result: 1
BUILD SUCCESSFUL (total time: 0 seconds)
I am using Netbeans 7.0.1 since it was the IDE I was using a couple of years ago to code java. I googled the error and found something about the class path but all the example I found were for LINUX based OS so I am kinda lost as to how to set it right on Windows.
The class does exist, the program did compile, from what I understand this error comes when the JVM tries to run the code and does not find the class.
Anyone can help me with finding the ClassPath on Netbeans 7.0.1 or if it is not the ClassPath finding why this error keeps popping up?
If you're trying to run your own code, setting your classpath is probably barking up the wrong tree. Netbeans should be including your code automatically on the classpath when it tries to run it.
Please describe how you have your code laid out within your project (eg do you have LOG120Devoir1.java in a log120/devoir1 directory?) as well as how you told netbeans that you wanted to run that class as your main method.
I get the following message when trying to execute etherpad/bin/run-local.sh:
Exception in thread "main" java.lang.NoClassDefFoundError: net/appjet/oui/main
I created CLASSPATH variable,
export CLASSPATH="/home/user/src/etherpad/trunk/infrastructure/build"
but that didn't help either. Although I can clearly see net/appjet/oui package in the build directory.
Looks like this has been figured out:
http://groups.google.com/group/etherpad-open-source-discuss/browse_thread/thread/2d877d1b585e159c
I'm using the JDK 3.1. I am using XML Publisher. I'm getting this error:
Could not find the main class. Program will exit.
After I click on "OK", I get
Java execution failed. Please check the Java Option in the option dialog
Sounds like you're trying to execute .jar file and there's no Main-Class entry in the manifest file. Other than that obvious point, your question does not give much information for assistance.
Your question is tricky to understand, but I'm guessing that you haven't actually compiled your Java code, or your compiled code isn't on the classpath.
When I try and execute a non-existent class (this would work if there was a MyClass.class on the classpath with a main() method):
paul#paul-laptop:~$ java MyClass
Exception in thread "main" java.lang.NoClassDefFoundError: MyClass
Caused by: java.lang.ClassNotFoundException: MyClass
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:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
Could not find the main class: MyClass. Program will exit.
Is that what you're seeing? If so:
compile your class with javac if you haven't done so
check that your classpath includes the location of the class
(You can specify the classpath explicitly when you execute the java program using -classpath, check the documentation for details.)
I include this answer as someone who has made an error someone consuming java rather than programming in it would make:
On the command line when executing a JAR file, be sure your line reads
java -jar whatever.jar
instead of
java whatever.jar
Without the -jar you sometimes get the "Could not find the main class" error.
Here are some good answers What does "Could not find or load main class" mean?
But, I will share one possibility I had. I used the JDK1.7 to compile my code and run the jar package using the JDK1.6, the error is:
Could not find the main class. Program will exit.
So, check if the JDK version you used to run your code is lower than that used to compile your code.
Check this website: "Could not find main class" error when previewing BI Publisher for Word. It directly references Java issues with Oracle BI Publisher Plugins for Word.
It basically says that you need to set your Java Home by going to Options in the BI Publisher Tab in the MS Office Ribbon.