Java SDK Mismatch - java

I have an old WebSphere app that I'm trying to compile with Java 1.5. I'm working in in IntelliJ on Windows 10. In my Project Settings I have the Project SDK set as:
1.5 (java version "1.5.0_22")
I also have 1.8 available, but it's definitely not what's selected in the Project SDK.
When I do a rebuild on my project I see:
Information:javac 1.8.0_152-release was used to compile java sources
It seems to build just fine, but when I try to visit my local website I see:
Error 500: (PathToMYServletGoesHere) bad major version at offset=6
I understand that this is error is related to a version mismatch.
Thanks

Related

How to Use Java 8 settings to build project in eclipse 4.18(2020-12)

*Due to some project requirements I "have" to use eclipse 4.18 (2020-12) which uses Java 11 by default and is mandatory to start.
But my entire project is/was written in Java 1.7 earlier. Now , in my mac i have both java 1.8 and 11 installed also my eclipse settings are such shown below.
I have made sure removed all java 11 references in my eclipse and made the project and workspace configure to take the 1.8 jdk and run at 1.7 compiler level.*
but when i run ,project -->clean-->build, i run into the JaxB missing in java 11 ( in java 11 JAXB was removed and my project uses jaxB extensively) This is known.
So i am wondering what am i missing that my projects are still building my project with java 11 and not java 1.7 (using jdk 1.8 configured).
Please help.. stuck on this since some days.
machome
Eclipse Compiler setting-1
Eclipse Setting Execution Envs
Eclipse installed JRE's
Eclipse Project specific setting
Java 11 JaxB error
If Eclipse itself is being run with Java 11, and you have a plug-in installed that has not been properly update to work under Java 11, as it appears, you will need an updated version of that plug-in. Update to the latest "oracle design studio", and if you still see this problem, contact Oracle support.
The latest Eclipse may require Java 11 to run, but it's simple to set up Eclipse projects that use older Java versions. Don't mess with the Java version it uses to start up, as long as that is a proper Java 11 version.
As one commenter mentions, you'll have to have a particular Java distribution configured in "Installed JREs->Execution Environments", and then you'll have to have the project configured to use that Java version symbol, like "JavaSE-1.7".

Android Studio - Could not determine Java version using executable

I'm using macOS 11.3 and I currently have an Android project with the Android Gradle plugin version 3.2.1 and Gradle version 3.4 that I'm trying to compile with Android Studio 4.2.1. As this version of Android Studio comes with JDK 11 as a runtime, I've tried to change the runtime of the IDE as detailed here and here
but I'm getting the following error:
Could not determine Java version using executable /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java.
The project uses Gradle 3.4 which is incompatible with Java 10 or newer.
See details at https://github.com/gradle/gradle/issues/4503
Possible solution:
Upgrade Gradle wrapper to 4.8.1 version and re-import the project
Upgrading the Gradle version is not an option in my case due to it's a legacy project that is no longer maintained and in the end, I would have some other compilation problems.
What I've tried to do is change the JDK of Android Studio to use JDK 8 as detailed but I'm getting the error "Could not determine Java version using executable /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java."
Does anybody has had the same problem? Can it be related to the path set on the Java_HOME variable?
This seems to be similar to this.
You can uninstall all existing JDK versions including 11 and install Java 8. Then try again after setting version 8 in your Studio as well as in the environment variable (JAVA_HOME path).
Hope that works for you!

Compiling Android project with JDK 1.7

My Android project is set up to use Maven, so I imported into IntelliJ from the pom.xml file. The compiler settings in IntelliJ are correctly pointing to 1.7, but when I try to compile I get:
Error: java: javacTask: source release 1.7 requires target release 1.7
My settings for the maven compiler plugin has both source and target set to this, so that's not the problem. However, in the module settings I see that my module is using
Maven Android API 19 Platform (java version "1.6.0_37")
If I try changing this manually in IntelliJ when I open my project after closing it it gets set back. I think that it has something to do with the android-maven-plugin, but I don't see where to force it to use java 1.7.
There is nothing in the Android Maven Plugin that forces Java 6. It must have to do IntelliJ and its Maven integration somehow. Or some other related configuration.

How to add jdk8 in Eclipse Indigo

I just read How to have Eclipse use JDK8 to compile a project?
What i added jdk8 to eclipse as,
From the answers of How to have Eclipse use JDK8 to compile a project?
I tried to Update the JDT/Core, JDT/UI bundles from http://dist.springsource.com/snapshot/TOOLS/java8/e43
But it shows error as,
"Eclipse Java Development Tools Patch for Java 8 Support (BETA)" is not applicable to the current configuration and will not be installed.
"Eclipse Plug-in Development Environment Patch for Java 8 Support (BETA)" is not applicable to the current configuration and will not be installed.
How Can i fix it ?
I can say that Java 1.8 does in fact work with Eclipse Luna ( the beta version released around March 17, 2014) or later. I tried it and it was good.
Also, I noticed that in the Eclipse Marketplace, there are now plugins to install functionality into Kepler to support JDK1.8. I haven't tried the plugin myself though.
This is a old topic but I just wanted to point out that I have searched enough to find that Indigo version can't be updated to S.E 1.8 here the link which is given on eclipse website to update the Execution Environment but if you try it will throw error for Indigo.
Here is the link where the Information about execution environment is given.
This shows the step by step to update Execution environment.
I have tried to update Execution environment and I got the same error.

GAE getting started in Java, Eclipse Indigo - can't compile as 1.6

I feel like I keep going in circles with this one. I followed the Getting Started guide for Google App Engine (https://developers.google.com/appengine/docs/java/gettingstarted/) in Eclipse and everything went relatively well until I uploaded it to the App Engine.
I was getting 500 errors so I checked the logs and found this: "guestbook/SignGuestbookServlet : Unsupported major.minor version 51.0]"
I then search for this problem (on stackoverflow, of course) and found this solution: Google App Engine and Java Version?
So I set the compliance level to 1.6 and then at the bottom of the dialog I get the warning that "When selecting 1.6 compliance, make sure to have a compatible JRE installed and activated (currently 1.7)".
I happy click OK, and it prompts for a rebuild. After the rebuild I then get this new error: "Java compiler level does not match the version of the installed Java project facet."
Not having knowingly used any facets in the project I do a search for some help (again on stackoverflow) and find this: "Faceted Project Prblem (Java Version Mismatch)" error message
Unfortunately it is not even close to being helpful because I am not used Maven, and when I bring up the properties of the project there is no Project Properties -> Project Facets panel for me to change a version on.
So it seems that I am stuck with something that either cannot be compiled in Eclipse or cannot be deployed to App Engine. I know that I am probably missing something obvious here but I can't quite put my finger on it.
UPDATE: I have uninstalled all JREs and JDKs, and reinstalled only jdk1.6.0_32. The problem continues exactly the same.
I had the same problem. I was able to resolve by using the Navigator view and editing the .settings/org.eclipse.wst.common.project.facet.core.xml, changing to:
<?xml version="1.0" encoding="UTF-8"?>
<faceted-project>
<installed facet="java" version="1.6"/>
</faceted-project>
After this change, the error went away and I could successfully run the GWT project in DevMode using jre1.7 but java 1.6 compliance level.
It really seems there should be a way to edit this java facet via project configuration, but I couldn't find it in Juno.
The answer, at least in my case, seems to be that if your Eclipse default compiler level is set to 1.7 when you create the Web Application then you can't switch it down to 1.6 successfully.
Example 1: Using JRE 1.6
In eclipse set Preferences->Java->Installed JREs to jdk 1.6.0_32
Set Preferences->Java->Compiler to compliance level 1.6
Use google plugin to create "New Web Application"
Run it locally - success
Deploy to app engine, run remotely - success
Example 2: Using JRE 1.7
In eclipse set Preferences->Java->Installed JREs to jdk 1.7.0_04
Set Preferences->Java->Compiler to compliance level 1.7
Use google plugin to create "New Web Application"
Run it locally - success
Upload to app engine - failure (Unsupported major.minor version 51.0)
In eclipse set Preferences->Java->Compiler to compliance level 1.6 - failure (won't compile locally (Java compiler level does not match the version of the installed Java project facet).
Solution:
Before using the google plugin to create the Web Application, switch the JRE and compiler level to 1.6 (as seen in example 1).
If your project already exists, then hopefully you haven't got too far with it and can create it again.
After fighting this issue for a few hours, deleting my nocache.js in the war folder was the final piece of the puzzle.
Contrary to the answer above, I was able to succesfully downgrade to compliance level 1.6 after creating the application in 1.7

Categories