Eclipse no reasons errors - java

i have been using eclipse, mars, neon and oxygen and i always had the same problem after some days/weeks of using its.
When i press run. It sometimes likes not to work and with no reason scream
Error: Could not find or load main class test.PingSwitchPing
and sometimes after i press run a few more times it suddenly works...
other times when i make some changes to code eclipse doesn't compile to make changes and run old code...
this time it is giving me something that it can't even replicate right now so i cant show error message, but basically the error was about not seeing class path to external libraries and to other parts of code that where in diffrent folder. While it was in phase on loading javafx application.
Why is it so unstable ? it is really piss me off becouse sometimes i am loosing hours to fight with it...
Sometimes i remove .m2 folder and redonwload everyting and it is helping. Cleaning project do nothing to this.
Sometimes restarting pc and eclipse works other times it dosen't...
I was just writing that i can't replicate main error but when i changed on line of code and run then it occurs. When i change it back nothing change. it still dosent work and dont want to work...
Exception in thread "JavaFX Application Thread" Exception in thread "main" java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at sun.launcher.LauncherHelper$FXHelper.main(Unknown Source)
Caused by: java.lang.NullPointerException
at com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:383)
at com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:328)
... 5 more
java.lang.NoClassDefFoundError: org/quartz/SchedulerException
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplicationWithArgs$155(LauncherImpl.java:352)
at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$174(PlatformImpl.java:326)
at com.sun.javafx.application.PlatformImpl.lambda$null$172(PlatformImpl.java:295)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$173(PlatformImpl.java:294)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$147(WinApplication.java:177)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: org.quartz.SchedulerException
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)
... 11 more
It once even let me write this
scene.getStylesheets().add("My.css");
and it worked event when this file was in .../workspace
when project was in .../workspace/MavenProjectName
It is just so unrelabile...

Related

Just upgraded to Windows 10 and Eclipse mars no more starts

I just upgraded to windows 10 and eclipse mars no more starts.
However my older eclipse v3.7.0 works all fine.
I followed the answers under this link:
Just installed Windows 10 and Eclipse no more starts
However it seems that I might have messed up something else too. Maybe deleted some files or dirs I am not able to figure out.
When I start eclipse I get this stack trace:
java.lang.RuntimeException: Error initializing storage.
at org.eclipse.osgi.internal.framework.EquinoxContainer.<init>(EquinoxContainer.java:77)
at org.eclipse.osgi.launch.Equinox.<init>(Equinox.java:31)
at org.eclipse.core.runtime.adaptor.EclipseStarter.startup(EclipseStarter.java:295)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:231)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:669)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:608)
at org.eclipse.equinox.launcher.Main.run(Main.java:1515)
Caused by: java.io.EOFException
at java.io.DataInputStream.readInt(Unknown Source)
at org.eclipse.osgi.container.ModuleDatabase$Persistence.readWire(ModuleDatabase.java:1168)
at org.eclipse.osgi.container.ModuleDatabase$Persistence.load(ModuleDatabase.java:1028)
at org.eclipse.osgi.container.ModuleDatabase.load(ModuleDatabase.java:879)
at org.eclipse.osgi.storage.Storage.<init>(Storage.java:146)
at org.eclipse.osgi.storage.Storage.createStorage(Storage.java:86)
at org.eclipse.osgi.internal.framework.EquinoxContainer.<init>(EquinoxContainer.java:75)
... 10 more
Please let me know what might be going wrong.
Thanks
Sachin

Weird ClassNotFoundException

This line of code is working fine when I debug in eclipse.
this.primaryStage.addEventHandler(KeyEvent.KEY_PRESSED, new EventHandler<KeyEvent>() {
#Override
public void handle(KeyEvent keyEvent) {
InputManager.Instance().addEvent(keyEvent);
}
});
When I export it into .jar ussing my own code (not script), it throws a rather long exception.
Exception in Application start method
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(Unk
nown Source)
at com.sun.javafx.application.LauncherImpl.launchApplication(Unknown Sou
rce)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at sun.launcher.LauncherHelper$FXHelper.main(Unknown Source)
Caused by: java.lang.RuntimeException: Exception in Application start method
at com.sun.javafx.application.LauncherImpl.launchApplication1(Unknown So
urce)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$156(
Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NoClassDefFoundError: test/Game$1
at test.Game.start(Game.java:62)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$163
(Unknown Source)
at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$176(Unknown
Source)
at com.sun.javafx.application.PlatformImpl.lambda$null$174(Unknown Sourc
e)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$175(Unknown S
ource)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(Unknown Source)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$149(Unknown Source)
... 1 more
Caused by: java.lang.ClassNotFoundException: test.Game$1
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)
... 10 more
Exception running application test.Game
Yet when I export it the same way, but with the handler commented out, it works fine.
I have tried root.addEventHandler, root/primaryStage.setOnKeyPressed, declaring the handler separately, ..
Can you spot the ex reason?
export it into .jar using my own code
Your "own code" is not doing it right, because it is not including the test/Game$1.class file in the .jar file.
Your class is called Game in the test package. When the class uses anonymous classes, those classes must be given a name in order for the .class file to be created (also need the name internally). The name of such files can be anything, but the current scheme is to name it after the defining class, adding a sequence number after a $ sign, so the first anonymous class is called Game$1.class, the second would be called Game$2.class, and so on.
That is why, when you compile Game.java, you end up with 2 files: Game.class and Game$1.class. Both of those files must be added to the .jar file.
You shouldn't rely on this naming convention, if at all possible, because it could change in the future, and other compilers might do it differently.
ClassNotFound exception is usually due to your CLASSPATH environment variable not getting set correctly.
The JVM must have transversed everywhere from the CLASSPATH directory but was not able to find your compiled *.class and java jar files. One way to fix this would be to use the -cp option from the java binary. Or you can set your CLASSPATH environment to the directory where your java files are sitting.
Things run fine in Ecplipse because the classPath set to the workspace and the IDE has got this handled for you.
Read here for more information about CLASSPATH.
https://docs.oracle.com/javase/tutorial/essential/environment/paths.html

Successfully implementing external classes in Eclipse. (Java)

I have been trying to use this external class folder which was given from my programming lecturer a few months back. I followed people's explanations of how to add via "configure build class", and the application somewhat recognises the class because a shortlist of some of the methods are given. It also does not return any errors prior to runtime but once it's ran I get this:
Exception in thread "main" java.lang.NoClassDefFoundError: Console
at lab3.q2.main(q2.java:15)
Caused by: java.lang.ClassNotFoundException: Console
at java.net.URLClassLoader$1.run(Unknown Source)
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)
... 1 more
This is really frustrating as it works from the linux computers in my college without issue. The class file is just a variation of the scanner that we use for user i/o, I have it attached.
Console.class file

Java3D - Some classes not found but classpath is set correctly

I have a class that uses Java3D that successfully compiles, although when I try to run it it says: Exception in thread "main" java.lang.NoClassDefFoundError:
javax/media/j3d/Canvas3D,
With the following stack trace:
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
at java.lang.Class.getMethod0(Unknown Source)
at java.lang.Class.getMethod(Unknown Source)
at sun.launcher.LauncherHelper.getMainMethod(Unknown Source)
at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)
Caused by: java.lang.ClassNotFoundException: javax.media.j3d.Canvas3D
at java.net.URLClassLoader$1.run(Unknown Source)
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)
Stuff I have already tried:
I couldn't even get it to compile until I copied the Java3D jars into /jre/lib/ext/.
I have the latest Java, Java3D and I am using Notepad++ and I have tried reinstalling Java3D.
I have set the classpath/path correctly.
There are no errors in the code.
I can run normal Java applications I have created.
I have tried using the classpath thing when running the application (java -classpath blahblah ApplicationName).
I have checked inside the jars and the classes (including Canvas3D) are definitely in there.
Not everything you say is true.
IF the classes are in the jars, and IF you have set the classpath correctly, THEN you would not get this message.
I suspect you have a build path confused with a classpath (which is mostly associated with runtime, where build path is associated with compile time). Without knowing more details of your runtime environment, it's hard to be more specific.
It always puzzles me how someone with a problem they cannot solve asserts so definitely that all these things are set up "correctly": how do you know? Isn't the problem some evidence to the contrary, at least enough for a small doubt?

Error NoClassDefFoundError/ClassNotFoundException

after about a month of not opening eclipse at all, I get a strange error
java.lang.NoClassDefFoundError: Z
Caused by: java.lang.ClassNotFoundException: Z
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)
Exception in thread "main"
I don't really understand what it wants, it doesn't show me anything else, something about main class "Z" not being defined? but it is, isn't it?
[CODE][/CODE] doesn't work very well here so I'll put source here: http://pastebin.com/heMhDqU2
Thank you.
Edit 1: it shows me when I try to compile and run. Btw, indent code by using 4 spaces for 500 lines... seems kinda reduntant
Your code is fine it compiles here.
Most probably an eclipse error.
Try this.
Close eclipse
Start eclipse with the flag .../eclipse.exe -clean
Press Project -- > Clean

Categories