I recently upgraded to IntelliJ 14, then added Scala support.
My main files stopped running. For example the GUI file, which has no errors and is a totally self contained hello world style for testing this error:
Exception in thread "main" java.lang.ClassNotFoundException: GUI
It makes no sense and I'm pretty frustrated that the IntelliJ devs are slacking in not auto-detecting a solution to this. I have tried everything to fix it. From settings, compilers, to making the project from scratch.
I only had a bit of luck when making it from scratch, but as soon as I started to add my other files (files that were not even being used!) it starts with the error.
It seems that any files outside of the original project module (when creating a new project to test fix) will not run giving ClassNotFoundException.
This may be related to my other question: https://stackoverflow.com/questions/27516673/cannot-run-file-located-out-of-main-module-intellij-14-java-scala
Sample View of the problem
I had the same problem and was able to fix it by right clicking the directory my class was in, and clicking Mark as sources root. This should make your class discoverable and able to run.
Solution
Turns out that Make, No Error Check does not work the same for scala as it does for Java.
Errors in the scala files will cause an ambiguous error message on run, with no clear link to the error.
Fixing the scala files fixes the error.
In my case, the solution was at the JDK and java level.
When I set JDK 14 this error occurred.
So when I work with a scala project, I set java 8 everywhere in the project(module) settings and in the configuration of the main method.
In project(module) settings section: Project, Modules, SDK's
In main method settings: JRE
Related
I have what is probably a stupid question... but here goes anyway. Some years back, I wrote a "Star Trek" game in Java 8, using JavaFX and Eclipse IDE. The project grew to be fairly large, but it worked. When I finished, I made sure to export the project using Eclipse's File --> Export menu.
I recently grew nostalgic and decided to import the "Trek" project into Eclipse on my current laptop. (The original laptop died.) FYI, my current version of Eclipse is Version: 2018-12 (4.10.0), which I thought was pretty recent.
The project imported just fine, but Eclipse seems mystified by everything in it. For example, when I try to compile and run the project, this error comes up immediately:
Error: Could not find or load main class gameEngine.MainEventTrek
Caused by: java.lang.ClassNotFoundException: gameEngine.MainEventTrek
gameEngine.MainEventTrek contains the project's main() method. Eclipse can't find it??? But the java file is right there, right in the project's src directory:
That's not all. When I open the Java files, Eclipse seems ignorant of how to import common packages:
Look at that; Even line 1 has an error! ("The type java.lang.String cannot be resolved. It is indirectly referenced from required .class files") I can understand that Eclipse might not know about JavaFX - I can't remember if I installed it - but Eclipse doesn't seem to know about common packages like java.math and java.util. Heck, later in my code, Eclipse doesn't know what the System package is, so all my System.out.println() commands are now throwing errors.
I'm a fairly good Java coder, but I'm pretty stupid when it comes to resolving basic compiler issues like this. Does anyone have any idea what the issue might be and how I go about fixing this? Thanks... and Live Long and Prosper.
The problem: I strongly suspect WindowBuilder makes my Eclipse crashing under certain conditions. These conditions are:
the class you're working on it using the design tab has to contain some references to a JavaFX code
first time you design such class it's all good. Second time you click on design tab of another class of that kind, or click on "Reparse source and refresh design page" icon inside the design view of the first class, Eclipse crashes. Essentially, parsing the code of such classes for a second time is where it crashes.
My context: I'm coding a gui hangman game using Swing and JavaFX libs. I'm aware of the conditions for interoperability between these two guys.
I'm using Eclipse IDE for Java Developers Version: 2021-12 (4.22.0) (the current one the installer installs on your computer). The JDK 17.0.1 (installer on Oracle site for Windows x64) and I'm on Windows 10 x64.
Enviroment variables (JAVA_HOME and PATH_TO_FX) and Eclipse project settings (non modular project is my case) should be ok: my code is compiled, my program runs without troubles, I see the gui and everything is where it should be and working. But to be sure I've tried to reproduce the crash with the code of more experienced people of me for sure (article link, repository link) and it crashes in the same way. I'm gonna post my code if required of course.
I'm using WindowBuilder 1.9.8, the last good build, cause a bug me and other people have encountered (see here, here and here) has been fixed there. Anyway, it crashes even with previous versions.
I'm gonna post a bunch of additional info about logs and crash reports, please skip it to the end if you think there's no need of additional info.
I'm running Eclipse with the -consoleLog parameter in the .ini file to have the log in a shell window at runtime. This is the relevant part of the log once it ends to load Eclipse:
java.lang.Error: SWT Resource was not properly disposed
and this is what it says when I click on the design tab of a JavaFX referenced class:
com.sun.javafx.application.PlatformImpl startup WARNING: Unsupported
JavaFX configuration: classes were loaded from 'unnamed module
#3d79168b'
but as I said, my project settings should be ok: running configurations -> java application -> main class -> vm arguments:
--module-path ${PATH_TO_FX} --add-modules=javafx.graphics,javafx.controls,javafx.fxml,javafx.base,javafx.media,javafx.web,javafx.swing
Yes, I know there's no need to load all modules, but just to be sure. And yes, I've even read this, but seems like I'm getting this warning anyway.
When I click on the "Reparse source and refresh design page" icon inside the design view, It freezes and have to terminate the process. The crash report says:
"Java was started but returned exit code= -8053063696"
So I looked for it, found this, tried everything (even to unistall the jdk, eclipse including the .p2 folder), but still the same problem
When I try to open the design tab on another JavaFX related class the crash report is different:
"Java was started but returned exit code= 1"
So I've read this, but my enviroment variables should be properly setted and everything should be correctly installed. I've even edit the .ini file to add the reference to the Java Virtual Machine dll, but still the same problem.
My question: can you reproduce this crash? There's a fix or I'm doing something wrong?
p.s.
I'm getting the "Wait! Some of your past questions have not been well-received, and you're in danger of being blocked from asking any more." warning here on stackoverflow :( I've read this and I hope this question it's ok
I installed Java & Eclipse and wanted to run the tutorial of the Hello World project.
As soon as I start with the first real step, creating a Java Project, I do everything alike the Tutorial, write the name "HelloWorld", finish.
Then a Window pops up, that wants me to create a new module-info.java. That is pretty strange, I have not seen anything like this in a Tutorial anywhere, but either way, if I create it or not, I get an error:
Errors occurred during the build.
Errors running builder 'Java Builder' on project 'HiWorld'.
java.lang.NullPointerException
Does anyone know something about this issue?
I have already tried to look in the Properties - Building Path, but when I add, remove, change something I do not get anywhere.
I had the idea that it could be a problem with my eclipse, but I reinstalled it twice already (Java as well) and I have not made any progress.
My code is just:
module helloworld {
}
I want to eliminate the error, so that later on my HelloWorld program is running.
Thank you for taking some time!
You don't mention the tutorial, but I imagine it's for below Java 9, of which module-info is part.
Go into Eclipse project settings and set language level to 8 (there's plenty of guides online) and you should be good.
Edit: If, however, the tutorial is for Java 9, I'd really recommend finding another tutorial as the module stuff is a whole set of extra complication which you don't need right away (I've yet to see Java 9 used in the real world)
I've got some class files that open in Netbeans (with .java extension) but in Eclipse I had the following experience:
At first I could not see the content of the class files with jadclipse and I only saw:
/jadclipse/
//Error!
A few days later (without any change to eclipse or ...) I could see them but with errors like the ones bellow:
"Couldn't fully decompile method ...
Couldn't resolve all exception handlers in method ...
Overlapped try statements detected. Not all exception handlers will be resolved in the method ..."
But the other day I ran into the first error that I could not see anything again!!!
OS: Win7
Java: 7
Netbeans 7.1.2
Eclipse version Juno Service Release 1
Any suggestion?
I didn't get any help on Eclipse plugin of JAD as I said it didn't work for my class files. So I tried Java Decompiler GUI and it worked very nice, therefore I wanted to share this nice experience so that it might be useful for some body.
I have been building my android app in an android eclipse environment. Building my c++ code and compiling it independantly with ndk-build. That works fine.
I need to debug a sigsegv error which is thrown by logcat all of a sudden.
So I switched the project in eclipse to 'add native code in android'. Now it debugs my c++ code, but gives me an error each time I use any of the std components, such as vector and so I cannot run the code since it contains errors.
The project ran fine on the previous config. I added a lib for std support I believe.
Any idea on how I can properly debug my native code?
Thank you for the help
UPDATE
I totally reinstalled my sdk, eclipse (juno this time) and all plugings. No change. The error checking does not recognise java and std related stuff:
#include <jni.h>
using namespace std;
is underlined in red.
The rest of c++ is recognised properly.
UPDATE2
When I add ${NDKROOT}/sources/cxx-stl/gnu-libstdc++/include to Paths and Includes, The java statements are already included. Net the vectors yet, I also tried to add ${NDKROOT}/sources/cxx-stl/stlport/stlport but it did not fix the vector problem yet. If error checking is disabled, the project compiles and if I make a synthax error, the compiler warns me. That is ok for me.
You, probably, can, first, disable errors in Project Properties|C/C++ General|Code Analysis so your project compiles.
You can then check if the include paths in Project Properties|C/C++ General|Paths and Symbols are correct.
I have also heard that updating the ADT plugin may help.