Unable to run Java Applications in Eclipse [duplicate] - java

I'm trying to get started with Eclipse/Java/Scala on a MacBook. The installed JDK was 1.5. The SDT plugin for Scala requires 1.6 which was included in an OS update, but I also manually installed a package from Apple to update 1.6.
The problem is that I cannot run anything from Eclipse. I always get the following error:
An internal error occurred during: "Launching TestFooBasicTest".
Could not initialize class com.ibm.icu.impl.JavaTimeZone
I also tried to use the old 1.5 version, but to no avail.
What is going wrong here?

I had the same problem trying to run a scala program with Ubuntu 10.4 and stock eclipse (Galileo 3.5.2) and java (java-6-openJdk ) - and the scala pluging downloaded from scala site, of course. I fixed it by manually changing /usr/lib/eclipse/plugins/com.ibm.icu_4.0.1.v20100125.jar as suggested in this thread (btw I discovered that Emacs can change a jar file in place: nice):
http://www.eclipse.org/forums/index.php?t=msg&goto=488654
It's caused by ubuntu openjdk package with broken symbol links for TimeZone configuration. The best solution from forum thread is,
Reinstalling tzdata-java was the fix for me:
sudo apt-get --reinstall install tzdata-java

The problem is:
An internal error occurred during: "Launching TestFooBasicTest". Could not initialize class com.ibm.icu.impl.JavaTimeZone
A quick google search reveals that this class belongs to the IBM Globalization package ICU. http://www-01.ibm.com/software/globalization/icu/index.jsp
A guess would be that this is a package used internally by Scala that you have not installed properly, causing Scala startup to fail.

Make sure that you set java 1.6 in the run configuration (Run/Run configurations).

Did you upgrade to Snow Leopard? Are you using the Eclipse SWT/Carbon or the Eclipse SWT/Cocoa? I was seeing some strangeness with Eclipse after I upgraded to SL. Switching to the Eclipse SWT/Cocoa from Eclipse SWT/Carbon helped. Also restoring my 1.5 VM, which the SL install removes in a sneaky way(by deleting and leaving the symbolic link pointing to 1.6), helped me fix several issues with Java code that had natives(i.e. usb-serial port code).

Check what are the JVMs that Eclipse is aware of and where they are located (Preferences -> Java -> Installed JRE), and also check the run/debug configuration of your programs. By default, Eclipse knows about the JRE that was used to launch itself, and other JREs that you add manually. However, if you upgrade some components and the JREs changed, Eclipse can get "confused" about them.

I had this same issue with Eclipse on Windows. I tried a number of different things including a new hello world program in a new workspace. I finally got this to work by pointing Eclipse to a different JRE to execute with. I know that Apple provides the JRE for Mac, but it does seem like this issue is related to Eclipse having trouble with the JRE used to run Eclipse itself. See here for configuring which VM Eclipse executes with.

Related

How can I switch java verisons in intelliJ?

I'm using the linux beta installation on my chrome-book, and I'm trying to set up a project to use the jdk version 1.8. I previously had a project set up that uses jdk 1.11, and now it seems that even though the current project is configured to use jdk 1.8 in project settings etc, the maven installation used by intellij is still configured to use jdk 1.11. When I run java -version and mvn -verison in the intelliJ terminal, java 11 turns up. I tried changing the maven settings as well, but whenever I try to mvn compile and install, I get the following error:
/usr/lib/jvm/jdk1.8.0_271/bin/java: 1: /usr/lib/jvm/jdk1.8.0_271/bin/java: Syntax error: "(" unexpected
I can't figure out why this is happening, but it must be the fact that maven thinks this is java 11, when it's java 8. Does anyone know how to fix this?
CTRL-ALT-SHIFT-S / Project / Project SDK - you can choose existing or add configure another one
It turns out I had downloaded jdk-8u271-linux-arm64.tar.gz instead of jdk-8u271-linux-x64.tar.gz, which is why the code wasn't recognized after installing the jdk. Apparently the two are designed for different CPU architectures, and arm is for mobile devices, and wasn't compatible with my chromebook.

The type java.util.Comparator cannot be resolved

The type java.util.Comparator cannot be resolved. It is indirectly referenced from required .class files
I recently installed Java 8. While executing an application, I got above mentioned error can you please help me.
I am using:
Java - jdk1.8.0_51
Tomcat - apache-tomcat-5.5.26
Assuming you are using some IDE, like Eclipse. When you are using jdk 1.8 with IDE, you need to update your IDE to support version 1.8.
It does not matter you are using new jdk's feature or not, but compiler has to load new JRE files in order to compile your project.
If you are using IntelliJ, go to:
File/Settings/Build, Execution, Deployment/Compiler/Java Compiler
and make sure "Use compiler" and "Project bytecode version" have the right configuration.
I had this same error and tried many things to fix it, but finally worked was remarkably simple: It turns that I was simply using an older version of Eclipse that did not support a "Compliance Level" setting of Java that was as high as my JRE. I merely upgraded to a newer version and the problem went away.
From what I understand about "Compliance Level", it's the version of Java that your program is supposed to work on. That much I found out from reading stuff on the net. But what the other solutions did not mention is that your IDE has to be able to be set to a level as high as your JRE. In my case, I was using JRE 1.8, but the highest compliance level my older IDE supported was 1.6.
IMO, this situation should have been flagged as an error by Eclipse. But as it was, I wasted two nights trying to figure this out.
Your project build path could be referring to a jre instead of JDK.
Go to your build path. (In eclipse right click and choose build path).
Go to your libraries and replace the jre with the jdk.
pom.xml version is 1.6?
If this is the way,you would replace jdk1.8 with jdk1.6 ,and environment variable into jdk1.6。
Same strange problem occurred. It turned out that wrong jdk version was in JAVA_HOME
There you are I had the same issue but moment I saw your question i got it fixed. problem is you are not using old version since there is mismatch of referencing with new version. this error will come.
Work around:
1. Change your java version to old.(In my case I had to change to 7)
2. Update each libray and jar file compatible to java 8 that way it will refer java not class file
Here is the image of environment variable in my problem
check if build path is set to run with JDK. It is important point that JKD is software development kit while JRE is a runtime env. Advice who had this problem see the different between JDK, JRE and JVM. https://www.guru99.com/difference-between-jdk-jre-jvm.html

Updating Java and JRE are causing many errors in Eclipse

I'm using Eclipse to program Android applications, and when I opened the program yesterday, it popped up an error saying I need to install JRE - I've downloaded the JRE and installed it - when during the installation I got a message saying that the JAVA version I have on the computer (Version 7) is too old for the JRE (Version 8), and that I need to update the JAVA also.
I did so, and then opened up the Eclipse again - And all of the projects,that before worked great, are now full with errors.
I tried installing all of the SDK updates - didn't work, also tried uninstalling Eclipse and re-install it - also didn't work.
The errors I get are: "XXX cannot be resolved to a type" - in amost every single line in the project.
How do I fix it??
Thank you!!
android development tool(adt) are install.. and all update SDK and then import an old program.. Ithink then work.
I would suggest to check that your java build path is functioning properly. This kind of error for me usually means that eclipse cannot find the JRE installation.
Form eclipse you can go to Project->Properties and check for any errors there. Any inconsistency there would cause all your projects to fail.
First of all, you need the JDK installation, not JRE. Second, Android currently supports up to Java v7, which means you'll need to get JDK v7 from here. Make sure you download the correct 32-bit or 64-bit JDK version for your operating system.
Also, ensure your Android SDK and Android Development Tools (ADT) are on the same released version. Different versions of Android SDK and ADT can lead to many unforseen problems.

How to install Eclipse on OSX 10.9.4

I've seen similar questions, but nobody having the identical problem...
I installed eclipse.
Attempted to run, and it complained I had no Java engine (oops).
It offered to install Java 6. I accepted the offer and it did.
When I tried to run eclipse again it complained that it needed Java 7.
Downloaded and installed Java 7. It is the only version that shows in preferences.
Try to run eclipse again. It continues complaining that Java 6 is not sufficient and it requires Java 7.
There are many ways to achieve what you want. But just to add some options, you can achieve it without modifying the default java version.
You can use the
-vm
/path/to/jdk7/bin/java
Here you can see more examples http://wiki.eclipse.org/Eclipse.ini.
The file is in /opt/eclipse/Eclipse.app/Contents/MacOS/eclipse.ini (note that my eclipse installation is in /opt/eclipse).

Missing libraries with oracle-java7-jdk in eclipse on ubuntu 12.04

I recently installed the ubuntu 12.04 final beta
After installing the oracle jdk from the webupd8 ppa, launching eclipse failed complaining about a missing shared library.
Can't load library: /home/bob/.swt/lib/linux/x86_64/libswt-gtk-3740.so
I searched around, and found this quesion: Eclipse cannot load SWT libraries
As the OP recommended, I tried switching to open-jdk, and that worked wonderfully. The problem, however, is that I am working on a project that doesn't support openjdk.
I tried the second solution as well (the one by scott, which was just creating symbolic links to /usr/lib/jni/... in ~/.swt/lib/linux/x86_64/). Eclipse launches and everything is fine, but it still misses some libraries; this is what I get when i try to run my project:
Caused by: java.lang.UnsatisfiedLinkError: /tmp/libgdx/1352105074/libjogl_awt-linux64.so: libjawt.so: cannot open shared object file: No such file or directory
I know libjawt.so is somewhere on my computer:
$ locate libjawt.so
/usr/lib/jvm/java-6-openjdk-amd64/jre/lib/amd64/libjawt.so
/usr/lib/jvm/java-7-oracle/jre/lib/amd64/libjawt.so
But eclipse or java seems to think that libraries should be placed in ~/.swt/lib/linux/x86_64, isn't that weird?
Eclipse when launched defaults to its own internal JRE, as I understand. I recommend the following:
Modify your CLASSPATH variable to include the path to the desired libraries;
Set your JAVA_HOME to match the actual JAVA_HOME;
Setup Eclipse to launch from the desired JVM by customizing the eclipse.ini using this information: http://wiki.eclipse.org/FAQ_How_do_I_run_Eclipse%3F#eclipse.ini
Also, can you specify the -classpath option when Eclipse is launched?
Try downloading the latest version of Eclipse and running it. For some reason it works fine. I just ditched my older version of Eclipse. I hope this works for others!
Please note that there are two Java runtimes in play here. The one used to run Eclipse itself, and the one you want to run your code. They do not have to be the same!
I would suggest
Run Eclipse with a JDK that works
Download Oracle JDK manually and unzip it to a folder in your home directory
Tell Eclipse about this additional runtime (http://help.eclipse.org/mars/index.jsp?topic=%2Forg.eclipse.jdt.doc.user%2Ftasks%2Ftask-add_new_jre.htm)
Configure your project to use that JVM instead. (http://help.eclipse.org/mars/index.jsp?topic=%2Forg.eclipse.jdt.doc.user%2Ftasks%2Ftask-assign_default_jre.htm)
Now your own code is compiled against, and runs with Oracle Java.

Categories