Using eclipse with processing, cannot get java application to run - java

so i am just trying eclipse with processing and are having a problem with getting the java application to run.
I am basically following this tutorial: https://processing.org/tutorials/eclipse/
I have followed the steps but when i get to this part:
import processing.core.PApplet;
public class UsingProcessing extends PApplet{
public static void main(String[] args) {
PApplet.main("UsingProcessing");
}
}
No errors or nothing but when i press run (run as java application), a java program opens (no window, i can just see the program in the bottom part of the screen). Then it closes after a couple of seconds.
I also get the following errors:
java.lang.NoClassDefFoundError: com/apple/eawt/QuitHandler
at java.base/java.lang.Class.getDeclaredMethods0(Native Method)
at java.base/java.lang.Class.privateGetDeclaredMethods(Class.java:3119)
at java.base/java.lang.Class.getMethodsRecursive(Class.java:3260)
at java.base/java.lang.Class.getMethod0(Class.java:3246)
at java.base/java.lang.Class.getMethod(Class.java:2065)
at processing.core.PApplet.runSketch(PApplet.java:10707)
at processing.core.PApplet.main(PApplet.java:10504)
at processing.core.PApplet.main(PApplet.java:10486)
at UsingProcessing.main(UsingProcessing.java:6)
Caused by: java.lang.ClassNotFoundException: com.apple.eawt.QuitHandler
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:582)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:190)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:499)
... 9 more
That part of code should at least give me an empty sketch but i get nothing..
This guy got it to work but i cant.. https://www.youtube.com/watch?v=0cqSjyvA8EY
I can assure you that i have imported the processing library correct, so that is not where the problem lays. I believe that it is some problem with my java? I am using a macbook pro and the following java:
Java(TM) SE Runtime Environment 18.3 (build 10.0.1+10)
Java HotSpot(TM) 64-Bit Server VM 18.3 (build 10.0.1+10, mixed mode)
Thankful for all the help and I am kind of new to this so please be gentle if anything is wrong!
EDIT:
I have also tried with IntelliJ without luck, the same thing, java opens for a brief moment and then closes. This video was my guide: https://www.youtube.com/watch?v=_h2GZgnPcnM

I can assure you that i have imported the processing library correct, so that is not where the problem lays.
You need more than just the core.jar library. In your case you need whatever .jar file contains the com/apple/eawt/QuitHandler class.
This answer says that the .jar you're looking for comes with the Mac JDK. Try adding that .jar file to your classpath.

So i believe the problem is sort of solved. The problem was (i think) with the java that apple uses(?). So i downgraded to the Processing 2 core.jar and everything worked fine.
Found here: https://github.com/processing/processing/issues/5371
and a link that i did not fully understand : https://github.com/processing/processing/wiki/Supported-Platforms#java-9
The guy there suggests that you should downgrade your jdk(?), but I think that it was processing 2 that was discussed (when i did that it did not work). So for now, everything in eclipse done with processing has to be done with processing 2.
This is strange because the tutorial on processings website made it work with processing 3
EDIT: the previous answer was asked more than five years ago..

Related

Getting "java.lang.NoClassDefFoundError: Could not initialize class" only in QA environment, not locally?

I have seen this:
java.lang.NoClassDefFoundError: Could not initialize class XXX
And this: Different methodologies for solving bugs that only occur in production
But my question is, given what the first answer says about this problem, how could it be that I could be getting that error on only one of the two places? isn't this a pretty serious error that should prevent the program from compiling in any location? (I properly import the class in the file this error occurs.)
What differences between the two environments should I be looking for?
Other questions about the error I'm getting in QA indicate it could be some nested problem with the class itself, but like I said if that was the case why would it only happen in the QA environment? I can run jmeter load/endurance tests against my program all day long locally and not see this error.
Note, I don't handle the deployments to QA, but is there something I should ask the guy who does? Would run config differences be a potential cause?
The logs in splunk aren't super helpful, here's part of the exception of one instance of the error:
[https-jsse-nio-11402-exec-9] 28 Jun 2021 13:29:45,415+0000 ERROR GenericThrowableMapper [{applicationSystemCode=[removed]-app, clientIP=[removed], clusterId=[removed], containerId=[removed], correlationId=[removed], domainName=[removed], hostName=[removed], messageId=[removed], userId=[removed], webAnalyticsCorrelationId=|}]: java.lang.NoClassDefFoundError: Could not initialize class [removed].CDDConfig
at [removed].execute([removed]AggregationResource.java:77)
at [removed]AggregationResource$$FastClassBySpringCGLIB$$7a8c5a8e.invoke(<generated>)
It then goes on into package classes and all that for a bunch of lines. I add this to ask - maybe there's something else I should try to have it log?
This isn't much more than a spontaneous guess, but judging from experience, I suspect a JDK / JRE version error.
Classic case I witnessed: you compile something on your dev machine with, say, OpenJDK version 8.x.x. You commit / push, the Jenkins CICD pipe starts running, but someone configured its JAVA_HOME to some 11.x version JDK.
-> ClassNotFoundError, NoClassDef, etc.
If you do not do the deployment to QA yourself, can you check what JDK the code has been compiled with? Or ask the guy doing it for that info.

"JAVA Parse Exception" error in Qualimap after MacOSX upgrade

I recently upgraded my MacOSX system to Catalina and several files were placed automatically into "Relocated items" folder on my Desktop. I recently tried to run the following code which had previously worked:
qualimap bamqc -bam Sample1_sorted.bam -c -outdir QualiMap/Sample1_sorted
and received the following error:
Java HotSpot(TM) 64-Bit Server VM warning: Ignoring option MaxPermSize; support was removed in 8.0
Error: Unable to initialize main class org.bioinfo.ngs.qc.qualimap.main.NgsSmartMain
Caused by: java.lang.NoClassDefFoundError: org/apache/commons/cli/ParseException
I have seen many other posts related to this error but am unsure how to even go about trying some of the suggested solutions. I do not work directly with some of the applications/files mentioned in these forums, such as JAVA, Maven, AppAssembler, and the pom.xml file (I could not even find that file). As a result, I wished to ask about this error from the perspective of a biologist using qualimap.
How can I fix this error (with little knowledge of the above applications/files)? I can certainly work with these applications/files, but I would probably need more detailed/basic/low-level advice on how to access and modify them. Thank you!
It seems what qualimap is a java application someone else wrote. I would raise a ticket with whomever wrote this app.

can't run 3D scripts in Processing (Java / openGL-related?)

I have been running to the same problem in all versions of Processing (visual design software) that I have been using, namely I get a java / openGL-related error, when I try to run 3D scripts. More specifically, I am getting the following message:
java.lang.NoSuchMethodError: javax.media.opengl.GLDrawableFactory.initSingleton()V
at javax.media.opengl.GLProfile.initProfilesForDefaultDevices(GLProfile.java:1652)
at javax.media.opengl.GLProfile.access$000(GLProfile.java:77)
at javax.media.opengl.GLProfile$1.run(GLProfile.java:142)
at java.security.AccessController.doPrivileged(Native Method)
at javax.media.opengl.GLProfile.initSingleton(GLProfile.java:128)
at javax.media.opengl.GLProfile.getProfileMap(GLProfile.java:2149)
at javax.media.opengl.GLProfile.get(GLProfile.java:898)
at javax.media.opengl.GLProfile.getGL2ES1(GLProfile.java:789)
at processing.opengl.PJOGL.initSurface(PJOGL.java:250)
at processing.opengl.PGraphicsOpenGL.initPrimary(PGraphicsOpenGL.java:6310)
at processing.opengl.PGraphicsOpenGL.requestDraw(PGraphicsOpenGL.java:1653)
at processing.core.PApplet.run(PApplet.java:2256)
at java.lang.Thread.run(Thread.java:745)
Could not run the sketch (Target VM failed to initialize).
I have already looked online, but I was not able to find an answer that would give me some solution. I am using a MacBook Pro with OS X 10 (Yosemite) and I am running Processing 2.2.1. Any help would be really welcome.
Austin is right, look at this answer: https://stackoverflow.com/a/19838327/458157
OS X 10 still comes with an obsolete version of Java 3D installed by default and it brings an obsolete version of JOGL which is loaded in priority. This old version has no method called javax.media.opengl.GLDrawableFactory.initSingleton(). you can find more information about this concern in my tutorial: http://tinyurl.com/qyf995p

Fatal Error: Invalid Layout of java.lang.String at value

I got an extremely annyoing error in Eclipse (in the console):
Invalid layout of java.lang.String at value
A fatal error has been detected by the Java Runtime Environment:
Internal Error (javaClasses.cpp:129), pid=15238, tid=140306591237888
fatal error: Invalid layout of preloaded class
JRE version: 7.0_07-b10
Java VM: Java HotSpot(TM) 64-Bit Server VM (23.3-b01 mixed mode linux-amd64 compressed ops)
Failed to write core dump. Core dumps have been disabled. To enable core dumping, try ulimit -c unlimited" before starting Java again
An error report file with more information is saved as:
/home/till/workspace/Encrypt/hs_err_pid15238.log
If you would like to submit a bug report, please visit:
http://bugreport.sun.com/bugreport/crash.jsp
Log Download
I cant't make any sense of this, because even Eclipse doesn't display any errors (in the code editor)...
This is a real productivity-killer, because it blocks all progress.
If anyone has any ideas on how to solve this, please answer this question.
Thank you really much in advance,
Till
In case of an Android project, you have to remove Android Lib from the launch configuration for that specific class. Use the "walkthrough" below as a guide.
Project->Properties->Run/Debug Settings;
Select your Class and click "Edit";
Open the tab "Classpath" and remove Android Lib from "Bootstrap Entries";
Apply everything and Run the class again.
I had same problem,then(as Jeff Schultz said here) I tried:
Run As -> Android Application
and problem solved.But I don't know the reason that causes this problem.I hope this help you!
This happened to me after:
Inserting a class in the Android Application project where I had forgotten to remove public static void main(String args[]) function. (Had previously performed a quick test of the class).
Tried to run the Application while I had opened and focused the above class on Eclipse editor.
The funny thing was that, after the Eclipse error, no matter on what class I switched the focus on, when I was trying to run the application again, I was stuck with the same error.
Inspired by Odyr Sohn solution, I managed to solve the problem (from Project->Properties->Run/Debug Settings deleting the faulty Launch configuration), but as soon as I was trying to run the application from this class, the same thing was happening again. When I removed public static void main(String args[]) function from the class, the problem was solved for good.
You should make a run configuration for an "Android application". If you make it for "Java Application" by mistake this error will show.
Same thing happened to me. I created a TestActivity and I guess it had a public static void main(String args[]) function. I went into the properties and then the Run/Debug and deleted TestActivity and it worked just fine.
I had the same problem, solved it by:
Run->Run Configurations;
Click on left on "Android Application"-> Button on top "New";
then type in a name and "Browse" the Project -> works!
I had a similar problem on the fatal error: Invalid layout of preloaded class with Kepler Service Release 1 using windows 7.
Project -> Properties -> Java Build Path -> Order and Export --> check mark any
unchecked library or Android version and then hit OK. Then run as Android application.

deploy java app on Heroku launch.main error

I want to deploy a java appa on HEROKU. I am new to maven. I made all set up as per in the deploy a sample app to heroku (java+maven+ tomcat7)documentation.
and i made a bulid,It was successfull. But as soon i typed sh /target/bin/weapps i am getting the following error. Can anybody help me to sort out this issue.
Exception in thread "main" java.lang.NoClassDefFoundError: launch/Main
Caused by: java.lang.ClassNotFoundException: launch.Main</br>
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:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
Could not find the main class: launch.Main. Program will exit.
regards,
arunbv
I had a similar problem, I (well, almost) solved it this way, just remove:
<packaging>war</packaging>
from pom.xml. I know this is not an ideal solution, but somehow the embedded tomcat plugin doesn't work with war packaging!
I don't have enough points to comment, but what article are you following? Can you link it?
Based on the error, I suspect your Main.java is not in src/main/java/launch. If you follow these instructions, I think you should be able to clear up the error:
http://devcenter.heroku.com/articles/create-a-java-web-application-using-embedded-tomcat
If that's the article you're following and you're still having trouble, it may ease the problems you're having if you simply clone the sample repo:
git clone git://github.com/heroku/devcenter-embedded-tomcat.git
Since you said you are new to maven, I think the reason of this error is that you simply put your *.java code under the root folder of the project, while you are rather expected to put it under ./src/main/java/
This should work for you. I experienced the same problem and figured this out.
This is probably dead, but in case it helps people of the future.
I was getting up and running with a java app on Heroku, using an Ubuntu machine for development - and got this same Exception in thread "main" java.lang.NoClassDefFoundError.
Double check that you're using the same java compiler version as your java sdk version.
type java -version & javac -version. Make sure they are the same version.
If not, you can fix this by reconfiguring your environment to use the same for both.
Assuming you have downloaded and installed the java version you want to use, type :
`sudo update-alternatives --config java`
You'll get a nice menu with options
Selection Path Priority Status
------------------------------------------------------------
* 0 /usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java 1061 auto mode
1 /usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java 1061 manual mode
2 /usr/lib/jvm/jdk1.7.0/bin/java 1
Select the version you wish to use. Done.
Now try to build.

Categories