java.lang.NoClassDefFoundError in eclipse mac os x - java

I am running Mac OS X 10.5 and I using eclipse to code my java projects. Eclipse has been running fine until today when I suddenly get the error when I try to run my Main.java:
An internal error occurred during: "Launching Main".
java.lang.NoClassDefFoundError
I installed Java for Mac OS X 10.5 Update 4 from this page earlier today so I was wondering if that might caused a problem. I have tired reinstalling eclipse (latest version) and find people with similar problems online but have not managed to resolve it. I was wondering if anyone have any idea for a fix?
Update:
I first tried to clean up the project through eclipse but this did not work. I then entered the workspace file and removed the already compiled classes, figured it might have to do something with that but that didnt help either. I started a new workspace with a new project and i get the same error.
I then tried to add my owm JRE file manually. What i interesting though is that there is no 1.6.0/Home in the versions folder. But since 1.5.0 did not seem to be added in eclipse I added this from the Versions/1.5.0/Home but I still get the same error. This is starting to become really annoying since I use eclipse atleast 4 hours a day in school.
Maybe my whole java got messed up after the installation of the new Java SE 6? If so how do i revert to only 1.5.0_
Thank you for your replies!

I suspect your JRE install location has changed due to the update. Go to Window > Preferences > Installed JREs and add a new default JRE that points to your updated Java. Then eclipse will rebuild all projects and hopefully, things should be fine again.

Clean your project. This error means that there is a missing .class that was there during compilation.

Related

IntelliJ Cannot start under Java 1.8.0: Java 11 or later is required

I had some problems with JRE versions, so I tried to change it using the plugin Choose Runtime. I changed it to Java 1.8.0_112-release-287-b2. Now, when trying to start IntelliJ, i get an unsupported Java version error: Cannot start under Java 1.8.0_112-release-287-b2: Java 11 or later is required. I have tried to modify the runtime path in the ide64.exe.jdk file, but it seems like the old jdk IntelliJ ran on has been deleted. I also tried reinstalling intellij, no luck either. Anyone know how to get back the JDK? do I just download it from oracle and install it in the IdeaIC2020.3\jdks\ folder?
Thanks,
Jakob
I went to the jdks folder and deleted all contents. This fixed the issue. IntelliJ started without a problem.

IntelliJ IDEA: "cannot resolve symbol" for String, System and other Java classes

I recently downloaded IntelliJ IDEA to a different computer. On one computer it works fine on the other computer it is giving me this current issue.
When i open a new project with a template it automatically shows errors everywhere even though it allows the code to run and shows the output correctly: standard Java library classes like String and System are highlighted in red and the error tooltip says: "cannot resolve symbol".
I have tried "Invalidate caches/Restart", but it didn't help.
Check the JDK configuration Classpath tab in Project Structure | SDKs:
Also check that project and modules use the same JDK.
If it's empty, remove the JDK and add it again. It's not recommended to use JetBrains Runtime as your JDK, download and configure some different standalone JDK instead, 2020.1 version can download JDK for you.
Important notice
The bundled JRE is used for running the IDE itself,
and it's not sufficient for developing Java applications. Before you
start developing in Java, download and install a standalone JDK build.
I tried above, but no luck. I did get it working with File -> Invalidate Caches...
I selected all three checkboxes and then "Invalidate and Restart". That worked for me.
Often this means there is an issue with your java compiler. Normally this issue arises on an initial Intellij install. You can install/update the java compiler to get it working properly.
Go to the editor and type Ctrl + Alt + Shift + A . Then, a little bar pops down and you can select to either install the compiler, or configure it. Both times this happened to me, I just clicked install and once it was done, everything worked. If the install doesn't work, you can just reconfigure your compiler.
Removing the Java SDK and adding it back under File->Project Structure did it for me.
The only thing that worked for me (after hours of trying!) was to use the Android Studio's embedded JDK. "Invalidate caches/Restart" did not solve the issue, even using the same JDK version which was not coming with Android Studio was giving the Cannot resolve symbol 'String' errors. Wonder what's so special with this pre-packaged JDK! Hmmm
For me the solution seems to have been creating a new Run Configuration.
I had tried deleting the SDKs, and re-adding the one I needed but that did not clear the error. But creating a new Run Configuration did the trick.
I had this problem when I uninstalled JDK and re installed it, and when I was making a new project I had the uninstalled JDK file selected, which somehow caused the system to be in red and un run-able.

Project facet Java version 1.8 is not supported, Tomcat 9, Eclipse Oxygen

I am currently having an issue with setting up a Tomcat server to run a Java 8 servlet. I've included snippets of the settings that are relevant to the issue. As you can see, I have jdk-1.8 installed and bound to the project build path. I have spent hours trying to figure out why Eclipse keeps saying Java 1.8 is not supported by Tomcat 9. If you look in at the project facets runtimes, you'll see that the server shows jre-1.7 even though I have set the path to the jre-1.8. I'm convinced this is where the issue is, but I have no idea how to fix it. I've tried setting the same Tomcat server up on another machine with no problems so I'm confused as to why it isn't working on this one. The major difference between the two is that the one that works properly shows jre-1.8 in the runtimes.
I am using Eclipse Oxygen on Windows 10
So it looks like I had Java 1.7 still installed in my machine (Java 1.8 was there too) so I went ahead and uninstalled the older version and then I reinstalled Eclipse Oxygen. Everything works now. The runtimes are showing jre-1.8. I have not a single clue exactly why it wasn't working before; but if you have this same issue, try giving this a shot.

Java runtime enviroment missing even when updated

So, i have been looking for the answer for this but i havent found anything, and i cant just ignore it
the thing is that i have created a windows applicaction on Eclipse, and it works on my pc, now i want it to run on my customers pc but when i try to open it there it pops up an error.
I have been trying on my computer, unistalling all java folders and subfolders and i just resolve the problem by installing the latest java version
So i updated my customers pc to the latest java version, now we both have 1.8.0_91-b14 jre after checking on the cmd
Im bundling this specific version on launch4j jre + a minimum jre 1.4.0 jsut in case and im still getting the same error:
"This aplicattion was configured to bundled Java Runtime Enviroment
but the runtime is missing or corrupted"
any ideas?
on my program folder i dont add any jre folder, i guess its bundled inside the .exe am i wrong? i just have my exe, libraries(jars) and some config
it works on my pc so im pretty confused, and i found it difficult to know whats wrong

java.lang.NoClassDefFoundError on mac 10.5

My problem started the other day when I tried to run a jar file that was compiled in java 1.6 from a friend. I then got:
java.lang.NoClassDefFoundError
Since I was only using java 1.5 obviously. So I updated using the system update. This did not help and when I ran:
java -version
in the terminal it still said I had java 1.5. I then saw on the internet that there was an "java SE update 4" on apples download page available. I downloaded and installed this file but it still wouldn't work. I gave up and decided to go back to my programming in eclipse. When I tried to compile and run my application in eclipse I now recieved the same error java.lang.NoClassDefFoundError and it wouldnt let me proceed. I tried right clicking the project and viewing the properties but it wouldnt let me, just gave me another error. I figured I might messed something up when I installed the new java version so I tried reinstalling eclipse but it still gave me the same error. I tried creating a new workspace but that wouldnt help either. I then figured I would try to compile throught the terminal using:
javac main.java
java main
But I still get the same error. I went in under systems settings and diabled "java 1.6" and i tried creating new projects with both javaSE-5 and javaSE-6 but it just wont work. My thoughts now is if it has something to do with eclipse not being able to access the bin & src directories in the project directory but that should work if i reinstalled it? I also saw someone mention setting the classpath in os x but I don't know. I would really need some help solving this issue since a lot of my work rely on eclipse working. I would rather not have to reinstall the whole OS just because of this but if I can't get it to work I guess there is no other alternative.
Best Regards
Jonas Kristensson
"Reinstall the whole OS"? Good lord, no.
Your problems have nothing to do with the version of Java. You don't understand how CLASSPATH works.
The class you were trying to run wasn't on the CLASSPATH. If your friend gave you a JAR, you need to add it to your CLASSPATH and use the fully-resolved class name to run it.
A word of advice for your future mental health: When you have problems, don't assume the worst and jump to extreme measures. Try the simple solutions first.
I tried to run a jar file that was compiled in java 1.6 from a friend. ... Since I was only using java 1.5 obviously
Note that if this was really the case you'd get a java.lang.UnsupportedClassVersionError, since Java 5 can't run classes compiled for Java 6 (it might be able to do so, but the class files say "I'm Java 6+" (class version 50) and thus Java 5 would just refuse to run it (max class version in Java 5 would be 49).
Try to compile with
javac -source 1.5 target 1.5 .....

Categories

Resources