java glassfish jdk 7 jre 6 version conflict - conflict

Downloaded JDK 7 from Oracle Java (comes w Glassfish) and installed on a Windows 7 machine.
In the shell, when I issue these commands:
javac -version
java -version
... I get two different versions. The compiler seems to be Java 7 but the JRE appears to be Java 6. Obviously this is a problem because programs compiled in Java 7 throw exceptions when run in Java 6 JRE.
Question 1: why does a JDK have different versions for the javac.exe compiler and the java.exe?
Question 2: how is it expected to be setup to work?

Question 1: why does a JDK have different versions for the javac.exe compiler and the java.exe?
It doesn't. You already have a Java 6 JRE installed and this is in your PATH before the JDK 7's bin directory. Remove the JRE 6 bin directory from your PATH.
Question 2: how is it expected to be setup to work?
Make sure the bin directory of your Java 7 JDK is in the PATH and not the Java 6 JRE bin directory.
See the JDK Installation Guide, especially the part Updating the PATH Environment Variable.

You need to check you JAVA_HOME environment variable and make sure it points to the correct JDK, then check the 'path' environment variable and make sure you don't have duplicate jre/jdk paths there.

Related

Is jboss 4.2.2 GA compatible with java 11?

We have a product that is running fine with JBoss 4.2.2/java 7.
We are now moving to JDK 11. simply added java 11 in the classpath and tried starting the server.
Encountered below error
OpenJDK 64-Bit Server VM warning: Ignoring option MaxPermSize; support was removed in 8.0
-Djava.endorsed.dirs=C:\PathBuilder\GE\EMEA\vp\jboss\lib\endorsed is not supported. Endorsed standards and standalone APIs in modular form
will be supported via the concept of upgradeable modules.
removed below configurations from run.bat and started the server again
-XX:MaxPermSize=128m
"-Djava.endorsed.dirs=%JBOSS_ENDORSED_DIRS%"
now getting below error and which is
interrupting the ear deployment Caused by:
java.lang.ClassNotFoundException: No ClassLoaders found for:
org.omg.CORBA.Object
Is Java 4.2.2 compatible with JDK 11 or we need to update JBoss to 7.2 or latest versions?
can someone help with this or provide related links?
JBoss 4.2 is a very old and outdated version and it only tested with JDK 1.5 and 1.6 version. If you are upgrading your JDK to 11 then you should update the JBoss to 7.3 version which is the latest available GA release from Red Hat.
You can download the jdk files of older versions like jdk6 and then replace JAVA path in the jboss run file from "set JAVA=%JAVA_HOME%\bin\java" to
"set JAVA=C:\Users\jdk1.6.0_45\bin\java"
Of course it's better to upgrade to a higher JBoss version... But in case that's not possible, you can avoid the ClassNotFoundException for org.omg.CORBA.Object by placing rt.jar from Java 8 in your JBoss-libs folder.
With this configuration you can run older JBoss versions with Java 11.

IntelliJ add Java 11

I need to add my installed Java 11 version to the project settings, because of this error (Error:java: invalid source release: 11).
When i go to project structure -> Project settings -> Project there it just shows Java 1.8.
When i try to add "java-11-openjdk-amd64" it fails with the reason "The selected directory points to a JRE, not a JDK.".
java -version
openjdk version "11.0.4" 2019-07-16
OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.4+11)
OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11.0.4+11, mixed mode)
The java application is available in the Java Runtime Environment (JRE). The fact that java is available in version 11 does not necessarily mean that the Java Development Kit (JDK) is also installed for version 11. However, IntelliJ needs the JDK which includes tools like the compiler javac.
In order to use Java 11 in IntelliJ, you need to install the Java 11 JDK.
For example on Ubuntu you can do that by executing:
sudo apt install openjdk-11-jdk

Netbeans installer issue with jdk 11

I downloaded and installed jdk 11 and am now trying to install netbeans 8.2. But i get an error which states "JAVA SE was not found on this computer.Make sure JDK is properly installed and run installer again. You can specify valid JDK location using --javahome installer argument."
I created a JAVA_HOME variable and set the value to "C:\Program Files\Java\jdk-11.0.1\bin" and set the same value for PATH variable as well.
How do i fix this?
You face a couple of issues:
NetBeans 8.2 requires JDK 8, and it will not work with any version of Java > 8.
NetBeans does not yet support JDK 11, though the release of a new version which does (NetBeans 10) is imminent.
The easiest approach would be to remove JDK 11 (unless you need it for other reasons apart from NetBeans), install Java 8 then reinstall NetBeans 8.2. It used to be possible to download NetBeans 8.2 bundled with Java 8, but if you try that now Oracle will just redirect you to the Apache NetBeans 9.0 web site.
There is a newer release of NetBeans than 8.2, Apache NetBeans 9.0. While it supports Java 9 and Java 10, it also does not support Java 11.
Updated to reflect that NetBeans 10 was released on December 27, 2018:
If you really want to use Java 11 with NetBeans you can download the latest Jenkins build of the beta version of NetBeans 10 at your own risk.
If you want to use Java 11 with NetBeans then download NetBeans 10.0. The download is a zip file and it works on all platforms.
Find netbeans.conf file in C:\Program Files\NetBeans 8.1 RC\etc.
In that atlas you'll find the netbeans_jdkhome. Set it accordingly.
You can specify the JDK to use by installing from the command line. So install a JDK 8 (e.g. Azul Zulu Open JDK 8) and then launch the netbeans installer:
netbeans-8.2-javaee-windows.exe --javahome "c:\Program Files\Zulu\zulu-8"
Once the installation starts, you will be asked which JDK to use for the IDE; make sure to choose your JDK 8 instead of the JDK 11. I have used this to install NetBeans 8.2RC successfully on Windows 10.

IntelliJ always builds for Java 1.7

I have my ANT configured to use a 1.6 JDK, my ENV variables JRE_HOME and JDK home both point to JDK6.
If I modify the JDK 6 folder name in my File explorer then my ANT build fails, cannot find JDK, so I know for sure it is using the correct JDK. However the generated clases are always compiled against java 1.7. Why i this? (My generated classes will only run on a 1.7 jre, I get version error if i run on a 1.6 JRE) All my project/module settings are pointing to 1.6 jdk.
Looks like not all of your Module/Project settings point to JDK 1.7 or you are using in-process javac option in Settings | Compiler while running IDEA under JDK 1.7.
Also check additional javac command line options, it should not contain options like -source 1.7 -target 1.7.

Will installing different version of JRE in one server causes instability?

I am writing a java program using JAVA 6. Our company server is using JAVA 5. They refuse to upgrade it to 6, so the workaround would be install another JRE 6 inside the same machine. They wonder, will installing different version of JRE causes instability?
What the installation process do? Simply copy over the files and setting up environment variable? Will it change any registry or other setting?
Multiple JREs can reside on the same machine. However, if you install JRE6, that's the same as upgrading to Java 6. Java 6 is (as far as I can tell) able to run all older Java code. However, Java 6 binary (.class and .jar files) can not be executed using Java 5, unless they were compiled to target the previous version.
If you need to, you can target Java 5 using a Java 6 JDK. There are command line arguments for javac that you can use (or incorporate into Ant, and probably other build tools) to specify a target JRE. For example, if you used the -target 1.5 command-line option using your JDK, the .class or .jar files that are produced will be executable using the Java 5 JRE.
It's been a while since I have ran two JREs side-by-side, but unless things have changed, there will be two separate java.exe (on Windows, anyway) files - one for the previous Java 5 JRE and a new one for the Java 6 JRE. Due to naming, only one can be in the path at a time - all of the files have the same names, so you can't include the Java 5 and Java 6 java.exe at the same time and expect the right one to magically run. However, you can leave the Java 5 JRE in your path and manually invoke the Java 6 java.exe when you execute your application.
If you use JAVA_HOME set to the Java 5 JRE and set a new environment variable to the Java 6 Java Home, let's say JAVA_1.6, as long as you properly reference the right environment variable, you should be fine.
You can definitely have both. If you are "allowed" maybe you could bundle the jre you want with your app? This URL talks about how..
http://forums.sun.com/thread.jspa?threadID=708451