Have a java project with couple of main java classes in it. On server this program has to run using java 1.5 version.
Trying to setup the same in eclipse.
Project properties/Java compiler ---- set to 1.5
Project properties/Java build path ---- Added JRE library ---> J2SE-1.5
But, when running one of the main class in the project in eclipse getting error as
SEVERE: Java Runtime Environment (JRE) version 1.6 is not supported by this driver
what else do I need to do in eclipse to run the program using java 1.5??
Go to Window -> Preferences -> Java -> Compiler and choose the default compliance level as 1.5
In Project properties/Java compiler make sure that 'Enable project specific settings' is checked.
Also, I would double check the build path for duplicate JRE libraries
Related
I've recently updated to IntelliJ IDEA 2016.3 and I just noticed that whenever I have a project with a java 7 SDK selected, IntelliJ compiles the project with java 1.8.0_112-release (which must be a compiler bundled with IntelliJ because I have never installed it myself).
If I select a java 8 SDK other than the 1.8.0_112-release, IntelliJ compiles with that compiler.
If I have a java 7 SDK selected and run a main method in my project, IntelliJ uses that java 7 SDK version to run so the issues seems to only relate to the compiler.
I have tried re-installing all my java installations.
When I change the SDK I usually only change Project Structure -> Project -> Project SDK, but I also verify that the Language level is correct and that Project Structure -> Modules -> Dependencies -> Module SDK is correct.
All settings are default under:
Settings -> Build, Execution, Deployment -> Compiler/Java Compiler
It seems to me that IntelliJ IDEA 2016.3 is not able to use a java compiler lower than java 8, but my googling attempts have not been able to confirm this.
I can also mention that the only thing I haven't tried yet is a hard uninstall of IntelliJ where all my settings are wiped as well. A silent uninstall have been tried.
If I try to compile a new Hello World project with a Java 7 SDK this is the output in the Messages tab: Information:Using javac 1.8.0_112-release to compile java sources. If however I set the project SDK to a Java 8 SDK this is the output in the Messages tab: Information:Using javac 1.8.0_45 to compile java sources.
Have tried setting Settings -> Build, Execution, Deployment -> Compiler -> Java Compiler -> Project bytecode version to 1.7 without any effect.
File -> Other Settings -> Default Project Structure -> Project SDK and Project language level set to the Java 7 SDK. Message tab still displays: Information:Using javac 1.8.0_112-release to compile java sources
Has anyone else experienced this and know what causes this behaviour?
You need to set 2 things:
CTRL + ALT + SHIFT + S --> Project --> Project SDK
CTRL + SHIFT + A --> Type "Java Compiler" --> Target Bytecode Version
Apparantley this was caused by an issue in IntelliJ as stated in this
issue.
It has been resolved as of IntelliJ IDEA version 2016.3.1 and I copy-paste the comment from Eugene Zhuravlev in the youtrack issue to explain how it has been fixed:
A new compiler option has been introduced for javac: File | Settings | Build, Execution, Deployment | Compiler | Java Compiler | "Use compiler from module target JDK when possible". The default value is "on".
When this property is enabled and JDK associated with the module differs from the build's own JDK, the build will prefer compiling with the javac from the associated JDK rather than the compiler from the JDK it runs on.
there is a distiction between Project Structure and Default Project Structure (the latter is for newly created/checked out Projects).
Default Project Structure hides in File -> Other Settings.
There you would have Project SDK and Project Language Level.
I started a new project that is just a hello world that has the Commons IO v2.4 Apache Library that uses JDK 1.6 but is unable to run after I build the jar. I added it to the Libraries and Modules just fine, and it executes the methods that I took from the libraries fine on Compile time, but I am using JRE 1.7. I took of the methods to prove that it is just the fact that it is interacting with this library. I did nothing else to this new project.
The JDK for the library is 1.6 but is demanding 1.8 JRE. Is there somethign that I'm missing here? I want to let users run my jar with their minimum JRE being 1.6 so I can target more users, but this is throwign an error.
The actual Error that is being thrown is the major.min error of 52.0, which means that it needs to run it at 1.8 JRE to run a simple hello world.
Try manually selecting language level for your project.
Right click project > Open Module Settings:
On right side under sources tab, change language level to required JDK.
Then click on Project tab on left and make sure both JDK version and language version are at correct version.
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 using spring tool suite IDE. I have imported one spring project. After running the project I get error as Fatal error compiling: tools.jar not found: C:\Program Files\Java\jre8\..\lib\tools.jar. I tried to use JDK's path in the preferences option. But then it shows another error as diamond operator is not supported in source 1.5. I am using JDK 8 and STS 3.6.3. Can anyone help me solving this error?
I get error as Fatal error compiling: tools.jar not found: C:\Program Files\Java\jre8..\lib\tools.jar.
Trying to use a JDK instead of JRE as you did is the right course of action for this error.
But then it shows another error as diamond operator is not supported in source 1.5.
It is possible to use Java 8 as a runtime yet compile using Java 5 as source and/or target level. This is really independent of the chosen runtime.
Check that you select at least Java 7 for 'source' and 'target' level if you want to use the '<>' operator in your code. This setting can be found by right clicking on your project and going to 'Properties >> Java Compiler'.
You can change these settings right there... but... depending on your project's setup this may not be the best idea. For example if your project is a maven project then you should configure compiler settings via maven compiler's plugin as shown here:
http://maven.apache.org/plugins/maven-compiler-plugin/examples/set-compiler-source-and-target.html
If you change the settings directly in Eclipse's UI those settings may be lost as soon as maven updates your project.
For that project, RightClick -> Properties -> Project Facets -> Change the java version to Java 1.7.
The diamond operator (empty "<>") was introduced in 1.7.
Check the Java version in the launch configuration wizard. Right-click on the project Run As -> Run Configurations... then select your project's launch config in the explorer on the left and check the contents of JRE tab on the right.
Also go to Preferences -> Java -> Compiler, ensure that Compiler Compliance Level is at to 1.7 at least.