I'm trying to install a java extension as a jar file. When I have just Oracle Java version 8 installed, I can run the jar-file.
However, when I download Eclipse, it includes openjkd7 and somehow this messes up my Java installation. When I include the jar file and try to run, I get:
Exception in thread "main" java.lang.UnsupportedClassVersionError:<path> Unsupported major.minor version 52.0
What is going on? Is Eclipse using a different version of Java? How can this be resolved?
I think you need to do the following things :
a.) Set the JAVA_HOME, probably should be the 1.8 version. Quit all instances of Eclipse.
b.) Re-open Eclipse. Then, In Eclipse, configure the Eclipse project Build Path to the 1.8...it SHOULD be the default JRE/JDK in Eclipse now, but it's hard to say since your installed Eclipse with a bundled JRE/JDK.
Right-click on the Eclipse project.
Build Path > Configure Build Path > Libraries (Tab) > Choose the JDK you want.
You can also configure Alternate versions of JRE/JDK from the screen...
Related
I'm trying to deploy the app with a .jsp file, which I figured is the reason I get an error because other projects without .jsp files have no problem.
When I try to deploy the app, I get the error : "Cannot get the System Java Compiler. Please use a JDK, not a JRE"
I tried resolving the problem using Mahmoud's solution here : Google app engine deployment : JDK not JRE
But once I have changed the eclipse.ini file, I launch Eclipse and get this error : "Version 1.7.0_80 of the JVM is not suitable for this product. Version 1.8 or greater is required"
You need to install JDK8 or JRE8 for Eclipse to execute and JDK7 for compile this application to build.
As mentioned in the error, JDK7 is not compatible with Eclipse. So you need to set your system JDK to 8 for Eclipse. Alternatively, you could instead modify the environment variables or startup script for Eclipse to reference JDK8 and avoid making this a system wide change.
Although for security purposes, I do recommend using the latest JDK/JRE as the system one for most cases.
Then within Eclipse, set the project JDK to 7.
Click through the following:
Windows -> Preferences -> Java -> Installed JRE
There you can remove the "JRE System Library", then you can add and configure another already installed JRE/JDK for this specific project.
You need the JDK for building which includes a JRE, but for deploying you only need the JRE.
The JDK includes the ability to compile Java source into executable code, where as the JRE can only execute that executable code.
You can download JDK from Oracle's site here: Oracle Java JDK 8
I have a Java Application on Eclipse using jdk1.7.0_72
I am having an issues when running a project from a runnable jar, the application works perfectly when ran from Eclipse. The application uses a cacert which for some reason fails when I use the runnable jar. What I have noticed is that the java version of the runnable jar is different when I run it from Eclipse. This is causing issues.
Here is a snippet of the system properties when I run from Eclipse:
**sun.boot.library.path=C:\Program Files\Java\jdk1.7.0_72\jre...
java.vm.version=24.72-b04
java.runtime.version=1.7.0_72-b14
java.awt.graphicsenv=sun.awt.Win32GraphicsEnvironment
java.endorsed.dirs=C:\Program Files\Java\jdk1.7.0_72\jre…
java.library.path=C:\Program Files\Java\jdk1.7.0_72\bin…**
Here is a snippet of the system properties when I run from JAR:
**sun.boot.library.path=C:\Program Files\Java\jre7\bin
java.vm.version=24.75-b04
java.runtime.version=1.7.0_75-b13
java.awt.graphicsenv=sun.awt.Win32GraphicsEnvironment
java.endorsed.dirs=C:\Program Files\Java\jre7\lib\endorsed
java.library.path=C:\Program Files\Java\jre7\bin;C:\Win…**
How can I make the JAR use the same version that Eclipse uses?
Also when I run java -version I get this:
"1.7.0_72"
When I click on About Java, I get this:
"1.7.0_75-b13"
If you run a JAR it'll use the Java version you set up on the PATH variable. If you run it from Eclipse you can tell Eclipse which version to use. As you can see the library.path variable is different, so you're loading a different Java in each case.
You can either set the proper Java version in the PATH variable or set it in Eclipse in the Preferences - Java - Installed JRE's menu.
It looks like you have at least two Java version installed on your machine.
Java 1.7.0_72-b14 is configured in your Eclipse
Java 1.7.0_75-b13 is configured in your PATH
You can change the java in your environment system variables according to this guide:
https://docs.oracle.com/javase/tutorial/essential/environment/paths.html
You are most definitely using different JRE's.
You have both the JDK and the JRE installed. It just so happens that the JDK has an internal JRE which you can see in the first line:
**sun.boot.library.path=C:\Program Files\Java\jdk1.7.0_72\jre...
The JRE is installed here
C:\Program Files\Java\jre7\bin
Your best option is to point Eclipse to execute your JAR using the installed JRE since the other option is to require the JAR to use the Eclipse JDK/JRE which would be problematic if you wanted to distribute the JAR to machines that didn't have Eclipse installed.
In Eclipse you can designate multiple JRE's and name them, create a new one and give it this path, then you can go to your project's run options and tell it to use this library when running your JAR.
"The java version of the runnable jar" cannot be different because of different execution environments: it's the JVM version.
The issue is that the jar is compiled with an higher version than the execution environment.
In the Eclipse IDE:
in Window/Preferences go to Java/Installed JREs
add your 1.7.0_72-b14 JRE
check the newly added JRE as the default for the workspace
Clean/recompile the project an re-export the jar file with File/Export/jar file
I have Java 8 and I've been trying to use a JAR package that uses JRE 6.
In 'Create a Java Project' I used the 'Use a project specific JRE' and also
created a run configuration but when I try to set the alternate JRE to 6, the 'run' button gets blocked out. Are they not compatible or am I missing a step? I've also tried changing the PATH destination, though I'm not sure if that is even relevant to my problem.
EDIT: I am using a JAR package from an online source that is Java 6 compatible and am trying to integrate it into Eclipse Mars with Java 8 installed.
A few items to check, under Project settings: (most of these can be set workspace-wide as well)
Java Build Path > Libraries. Replace JRE System Library with a jdk6 execution environment or alternate JRE
Java Compiler > JDK compliance. Set to 1.6
System:
Check Installed JREs and Execution environments. Make sure a JRE is linked to the Execution Environment for JavaSE-1.6 (with the checkbox).
Did you try just adding the external JAR to the project? Most (non-executable) JARs that were originally made for older versions of java should still work today.
To add an external JAR: right-click on your project in the package explorer and go to Build Path >> Add External Archives... then select your JAR from there. Be sure to leave the project set up for JRE8.
The reason that your run button is blocked out when you switched to JRE6 was because Eclipse detected that it was not installed and therefore cannot run it as JRE6.
While trying to do a maven compile goal on a jar project in eclipse it failed stating that there was no java compiler found. It showed that it was using the path to jre1.8.0_45. My configured java build path in eclipse is using jdk1.7.0_80 and is configured for the correct corresponding environment.
I tried to rename the jre directory while eclipse was open but it showed that something had a lock on it, and sure enough it was eclipse that was launching with jre1.8. If I renamed the jre1.8 directory while eclipse was closed, then it would not launch again complaining that it cant find the java directory.
I guess what I'm getting at here is, is this a bug with Mars? Or am I missing something because everything in Eclipse is pointed to 1.7.
Thanks,
Nate
You should point Eclipse to JDK installation.
Window -> Preferences -> Java\Installed JREs
click Add -> Select Standard VM, Next ->
and then in text box "JRE home" you should put path to JDK home,
it's quite misleading..
BTW you should specify java version in maven-compiler-plugin. M2E plugin will then recognize this settings and configure compiler appropriatelly
http://www.gamefromscratch.com/post/2011/11/15/Telling-Eclipse-to-use-the-JDK-instead-of-JRE.aspx
It's the launch configuration of any m2e build that should point to a full JDK, cf. http://help.eclipse.org/mars/topic/org.eclipse.jdt.doc.user/tasks/task-choose_config_jre.htm?cp=1_3_5_2 (except you will be using a Maven Build configuration, rather than a Java Application).
For most other situations using a JRE should be perfectly fine.
I am writing my code in eclipse, the code is running fine but when I try to build it in ant by running build.xml. I am getting
Java Virtual Machine Launcher: Could not find the main class. Program will exit.
Any suggestions?
if you are using java 1.6 and upgraded eclipse, it's more likely caused by eclipse the solution is to go to Run as → External tools configuration… → JRE where the default was set to “Separate JDK”: jdk1.6.0_31 and change this to “run in the same JRE as the workspace” (1.7/1.8), and it should works.
Bug fix would be to provide a working default configuration with setup. Configuration should be in a way it does not break if the user adds additional JDKs to Preferences.
for more details you can see Bug 472599
You need to verify few things
1) Is the path to java bin directory set properly?? (To check this you need to write command javac in command prompt(cmd) and you will get a list of instructions on cmd console) 2) Open the eclipse and go to Window-> Preferences-> Ant-> Runtime in the Classpath tab, see Ant Home Entries pointing to the wrong directory (it still points to the last directory, this directory does not exist) you have to do is to change the Ant Home pointing to the correct directory, to point Ant Home button select Ant Home directory, for example, I use Eclipse 3.3.1, Ant Home is the Eclipse plugin directory org.apache.ant_1. 7.0.v200706080842.
Right click on the build.xml file and select Run As --> External tool configurations --> Jre --> Select Run in the same JRE as the workspace.
If you are using Java 1.5 (that is, it is specified in your workspace, project or ant configuration as the JVM to use), it is also caused by a bug/feature in Eclipse: Java 1.5 is no longer supported. You need to upgrade to Java 1.6.
See: Eclipse bugs 421423
The version of ant you're using may not be compatible with the version of java you are using. I have ant 1.9.4 and was trying to run with java 1.4 and got this same error. Running with java 1.7 fixed it for me!
Error I was facing :
"Could not find the main class :
org.eclipse.ant.internal.launching.remote.internalAntRunner. Program will exit."
To compile my code with JDK 1.8, i have added external ANT to my eclipse, which was working fine. But compiling the code with JDK 1.6 with same ANT version was not working.
Solution : I restored the ANT in to its default value by selecting " Restore Default Entries " ( ANT --> Run as --> External Tools configurations --> classpath" ), after that ANT with JDK 1.6 is working fine.
Above error was happening for me when i added external ANT to my eclipse which was compatible with JDK 1.8 usage. Ant was working with JDK 1.8, the same was not working with 1.6 JDK. Once i restored ANT classpath settings to its default eclipse values which was JDK 1.6 compatable, above error was gone.