Running Java app from inside emacs using JDEE throws NoClassDefFoundError - java

I have configured JDEE in emacs. But when I try to run any App, it throws NoClassDefFoundError .
Upon compilation, although a class file is created, it only shows the buffer for sometime and then closes it.
The same files if compiled and run from the terminal work perfectly fine.
Also, on this machine I have java-6-openjdk installed. I had configured JDEE on my home computer which has sun java jdk and there are no such problems there.
Other than this, features such as code completion, generation etc work fine.
How do I solve this? Is this due to open jdk ?
I am using a Ubuntu 10.04 desktop.
This is the stack trace
cd /home/vineet/java/KodeJava/src/org/kodeplay/kodejava/
/usr/lib/jvm/java-6-openjdk/bin/java org.kodeplay.kodejava.EmacsTest
Exception in thread "main" java.lang.NoClassDefFoundError: org/kodeplay/kodejava/EmacsTest
Caused by: java.lang.ClassNotFoundException: org.kodeplay.kodejava.EmacsTest
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: org.kodeplay.kodejava.EmacsTest. Program will exit.
Process org.kodeplay.kodejava.EmacsTest exited abnormally with code 1
Thanks

something in your config is wrong. you are trying to run from the "/home/vineet/java/KodeJava/src/org/kodeplay/kodejava/" directory, but in order to find your class on the classpath, you should be running from "/home/vineet/java/KodeJava/src/". Probably need to configure the "jde-run-working-directory" variable.

From the question, it sounds as if the JDEE configuration is not complete when it comes to setting up the command to be launched when running the Java App.
If the same Java App can be run from the terminal with no issues, OpenJDK is not causing the trouble, I'd wager.
Perhaps you copied over from the other computer the JDEE configurations and did not adopt them for the new computer that has OpenJDK.

Related

Sentry intialization crashes with a NoSuchMethodError trying to find jdk.internal.reflect.Reflection.registerMethodsToFilter

I'm using jpackage (part of jdk14+) to build an MSI for windows installation of my java application. Everything packages and installs fine, but when I go to run the .exe it throws an exception while trying to initialize Sentry.
Exception in thread "main" java.lang.NoSuchMethodError: 'void jdk.internal.reflect.Reflection.registerMethodsToFilter(java.lang.Class, java.lang.String[])'
at sun.misc.Unsafe.<clinit>(Unsafe.java:59)
at java.base/java.lang.Class.forName0(Native Method)
at java.base/java.lang.Class.forName(Unknown Source)
at com.google.gson.internal.reflect.UnsafeReflectionAccessor.getUnsafeInstance(UnsafeReflectionAccessor.java:70)
at com.google.gson.internal.reflect.UnsafeReflectionAccessor.<init>(UnsafeReflectionAccessor.java:34)
at com.google.gson.internal.reflect.ReflectionAccessor.<clinit>(ReflectionAccessor.java:36)
at com.google.gson.internal.ConstructorConstructor.<init>(ConstructorConstructor.java:51)
at com.google.gson.Gson.<init>(Gson.java:206)
at com.google.gson.GsonBuilder.create(GsonBuilder.java:597)
at io.sentry.EnvelopeReader.<init>(EnvelopeReader.java:28)
at io.sentry.SentryOptions.<init>(SentryOptions.java:89)
at io.sentry.SentryOptions.empty(SentryOptions.java:1559)
at io.sentry.NoOpHub.<init>(NoOpHub.java:15)
at io.sentry.NoOpHub.<clinit>(NoOpHub.java:13)
at io.sentry.Sentry.<clinit>(Sentry.java:24)
This is using the latest sentry 5.2.0 library (tested all the way back to 4.2 and it still has the error though), and have tested JDK 14 through 17 to see if any of them work, which they don't.
Everything works fine if I'm running the .jar with java -jar program.jar, but it seems like jpackage creates an executable that doesn't work quite the same as simply running java.
The call to jpackage needed --add-modules jdk.internal.vm.compiler to fix this in JDK14, and by JDK17 it needs to be --add-modules jdk.unsupported instead.

Exception in thread "WindowsNativeRunloopThread" java.lang.NoSuchMethodError: <init> when I execute a .jar file

This evening, I downloaded a .jar file from Jsqlquiz website. However, when I try to execute it in the terminal, I have these two displayed exceptions (I'm on Windows 10) :
Exception in thread "WindowsNativeRunloopThread" java.lang.NoSuchMethodError:
at com.sun.glass.ui.win.WinApplication.staticScreen_getScreens(Native Method)
at com.sun.glass.ui.Screen.initScreens(Screen.java:412)
at com.sun.glass.ui.Application.lambda$run$1(Application.java:152)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:174)
at java.base/java.lang.Thread.run(Thread.java:830)
and
Exception in thread "JavaFX Application Thread" java.lang.NullPointerException
at com.sun.prism.d3d.D3DPipeline.getAdapterOrdinal(D3DPipeline.java:205)
at com.sun.javafx.tk.quantum.QuantumToolkit.assignScreensAdapters(QuantumToolkit.java:695)
at com.sun.javafx.tk.quantum.QuantumToolkit.runToolkit(QuantumToolkit.java:313)
at com.sun.javafx.tk.quantum.QuantumToolkit.lambda$startup$10(QuantumToolkit.java:258)
at com.sun.glass.ui.Application.lambda$run$1(Application.java:153)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:174)
at java.base/java.lang.Thread.run(Thread.java:830)
I check my java's versions to see if I have a bad/old one, but all is on date :
JDK 13.0.1
JRE 1.8.0_241
JavaFX 11.0.2
I found answers on this forum but none helped me. :
Write java -jar filename.jar in a .bat file and execute it.
Extract the folder and try to run it.
Place jdk-13.0.1\bin and Java\jre1.8.0_241\bin above the Common_Files\Oracle\Java\javapath (I deleted it finally, it was the easiest way to try to fix my problem).
If anyone here thinks they can help me, tell me! :)
Okay, after hours spent fixing my problem, I finally found it for myself!
For all those who have the same problem, follow what I will say:
There must be ONLY one version of Java on your pc (wether it's the JDK or JRE). So, only keep the java version you want and try to compile your file with java -jar fileName.jar and it should work.
I myself had the JDK and the JRE, both added to the path of the environment variables. So the error came from here.
The only thing I don't understand is why the JRE created a problem during the execution when I had put the path of the JDK above.

VisualVM is unable to profile a web application on Eclipse

I would like to profile my Spring Web Application that is running on Tomcat and Eclipse. I added VisualVM to the Eclipse and followed below steps to run the application for profiling.
Right click on the application name >
Run As >
Run Configuration >
Java Application >
'Selected Project' >
Set 'org.apache.catalina.starup.Boostrap' as a value for Main class,
also selected VisualVM as the Launcher > clicked on Run button.
The VisualVM starts but shows following message:
"Cannot open requested application"
Under local I can see VisualVM, Eclipse and Tomcat.
Following exception will be thrown and shown on console as well:
Exception in thread "main" java.lang.NoClassDefFoundError:
org/apache/juli/logging/LogFactory
at org.apache.catalina.startup.Bootstrap.<clinit>(Bootstrap.java:59)
Caused by: java.lang.ClassNotFoundException: org.apache.juli.logging.LogFactory
at java.net.URLClassLoader$1.run(URLClassLoader.java:372)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 1 more
I reckon the issue is because of wrong server selected. Maybe I should choose Tomcat but not sure how.
Probably an issue with an incomplete classpath when the VisualVM plugin launches Tomcat. You could try to correct the classpath of the start configuration which you created (e.g. try to add bin/tomcat-juli.jar from your tomcat installation) but I doubt this will work easily.
You can try the following:
start your Tomcat, e.g. from Eclipse
then manually start VisualVM: It is actually part of the JDK and located in <JDK dir>/bin/jvisualvm(.exe)
in the application list you should see the Tomcat process and then you can open it with a double click.
Try using Java Mission Control by running jmc. It is included in recent versions of the JDK.
See the getting started doc at http://docs.oracle.com/javacomponents/jmc-5-5/jmc-user-guide/index.html
Run your application, then open the jmc window and connect to the Tomcat process.
This is caused when a class file that your code depends on is not found at run time. This is purely an issue with the class path. Either the class is not exists in the class path or you have a different version of JAR file in the class path. The exception will go away if the class path is corrected.

Matlab has critical error from clean install (possibly OS X related?)

Using R2014b on OS X Yosemite.
Exception in thread "Startup Class Loader" java.lang.UnsatisfiedLinkError: jogamp.common.jvm.JVMUtil.initialize(Ljava/nio/ByteBuffer;)Z
at jogamp.common.jvm.JVMUtil.initialize(Native Method)
at jogamp.common.jvm.JVMUtil.<clinit>(JVMUtil.java:58)
at com.jogamp.common.os.Platform$1.run(Platform.java:212)
at java.security.AccessController.doPrivileged(Native Method)
at com.jogamp.common.os.Platform.<clinit>(Platform.java:179)
at javax.media.opengl.GLProfile.<clinit>(GLProfile.java:83)
at com.mathworks.hg.peer.JavaSceneServerPeer.initializeJOGL(JavaSceneServerPeer.java:114)
at com.mathworks.hg.peer.JavaSceneServerPeer.<clinit>(JavaSceneServerPeer.java:100)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:190)
at com.mathworks.mde.desk.StartupClassLoader.loadClass(StartupClassLoader.java:258)
at com.mathworks.mde.desk.StartupClassLoader.access$900(StartupClassLoader.java:25)
at com.mathworks.mde.desk.StartupClassLoader$2.run(StartupClassLoader.java:244)
at java.lang.Thread.run(Thread.java:745)
This pops up the moment I start matlab. I am unable to use imagesc() or imshow() and probably loads of other functions, because matlab crashes with Caught unexpected exception of unknown type. instantly.
I'm at my wits end. The matlab install is fresh, and so is the OS. Same problem using the Java from Apple or the Java from Oracle.
EDIT: Response from MathWorks is that integration with Maple breaks everything. Emptying the .maplerc.sh file in the /bin/ directory fixes everything.
This issue is caused by having installed Matlab integration through maple. A file called .maplerc.sh is placed within the /bin/ folder in the matlab .app, and it apparently breaks everything. You cannot delete the file (this causes matlab to not launch on start up) but you can erase its contents. This will create an error upon launch, but you can ignore it and everything will work fine.
Uninstall matlab and maple, and reinstall maple and matlab without integration will fix the issue entirely.
Replace the contents of the file /Applications/MATLAB_R2014b.app/bin/.maplerc.sh by an empty line (as suggested by the other answer from Dorako), and
Modify the file /Applications/MATLAB_R2014b.app/toolbox/local/matlabrc.m, by searching for Maple in this text file and comment-out or remove the part between the two lines containing %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%.
The second step ensures that there is no error or warning message any more on startup, so that re-installing the programs is not necessary.

What this following error means?

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

Categories

Resources