Properly install Java 9 along with Java 8 - java

How do you properly install java 9 along with java 8. I'm currently using Java 8 and Netbeans for a class, but I would like to have the ability to experiment with code using the new JShell. I just don't want to mess up my Netbeans configuration or any other JRE by installing Java 9. How can I do it safely and not disturb Netbeans and my current JRE?

You can give jEnv a try. It's a Java version manager (similar to those available in Ruby, Node etc). It allows you to switch between Java versions (locally, per project, per terminal etc). All the aliases are installed in ~/.jenv directory and will not impact you current working environment.
Once installed you can run Java9 just for current terminal session with jenv shell 9

You should install the latest NetBeans Development IDE, which is downloadable from here:NetBeans Dowload , installing it alongside NetBeans 8.2, for example, is easy as it will autodetect Java JDK 9 (assuming you have installed it) and import your existing settings.
In my case I found that you can't add the Java 9 platform to NetBeans 8.2. You have to install the JDK and then install the NetBeans Development build. Once installed you can use it to create modular projects and use Jshell.

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".

How can i use eclipse 2020-09 to develop java 8 projects?

I am a regular IntelliJ user, but most of my co-workers use Eclipse. A lot of them say the latest version of Eclipse "2020-09", which requires a JRE "higher than Java 8" in order to run, cannot be used to develop projects requiring JRE8.
This is pretty surprising to me, since I know it is possible to install multiple JDKs and JREs on one machine, I've done it plenty of times.
What is the typical way a person would configure Eclipse 2020-09 (already installed) to work on a project that requires a Java 8 JRE?
JRE 8 apps in eclipse workspace is possible by having the jre 8 jdk. It is true that in order to use eclipse 2020-09 you need java 11+ jdk/jre, but making projects that support jre 8 is still possible.Even I still use 2020-06 and before. Here is a method you could use to get JRE 8 implemented back in your project. Although you can change the defaults, this one will help you change the environment back to java 8 for 1 project.
Right click the library named somthing like "JRE system library[JavaSE-11]". Press properties. This is what you will see JRE System Library chooser image
Choose "Alternate JRE" then click "Installed JREs"Step Image
Press "Add" then you will see 3 options. Choose standard VM. Find your java 8 jdk directory. Usually it is something like C:\Program Files\Java\jdk1.8.0_251.
You can configure the default arguments for your jvm runtime. Then simply hit ok,select the jdk-8 library and close it. Then choose alternate jre again and in the drop-down choose jdk-1.8.0 or some name like that. This will only work if you also have java 8 installed alongside java 11 that is configured properly JDK
You can use Java 11 to start the Eclipse 2020-09 and configure a project to compile with Java 8. The problem is if you want a Eclipse plugin that uses CORBA for example. This module was removed from Java 11 earlier. In this case, I recommend to use Eclipse 2020-06.
Earlier versions of 2020-09 was working with Java 8. I had it, too. Then I updated and I got the same error message like you.
I propose to use an older one or to install JRE 11 and set the JAVA_HOME env variable to it.
The inside the IDE you can set java 8 like an JDK and develope your project with Java 8 while eclipse is running with 11.

Can't download Java 7 because my computer already has Java 8

I am trying to download Java 7 on my mac. All my professors require java code to be in Java 7. I have the dmg downloaded but when I double click the icon to install I get the error message :
A newer version of Java is already installed.
The only thing I can do is click close and it exits the install. How can I install Java 7 onto my machine?
If you are doing your "development" using an IDE like eclipse, there is a simple solution to your problem: within eclipse, you can change the "compatibility" mode for your projects.
Meaning - even when only Java8 is installed, you can instruct eclipse that your project should be using Java7 only. So when you write source code that uses Java8 features (like lambdas or such things); you will get compiler errors.
The only caveat: you still could be using classes/methods from the Java8 installation that don't exist in Java7.

Create Jar Compatible With Java 7 With IntelliJ Using JDK8

I am using JDK8 on my normal desktop and I have a separate linux box that I am trying to run the Java program on.
The problem I'm running into is that the linux box is running jdk7, so the computer has JRE7 basically that it is running off of. My question is, is it possible to create a jar file in JDK8 that will be compatible with java 7?
I'm using IntelliJ to compile. I tried to compile in 1.7, but it gave an error when I did end up trying to do it. I compile it here:
In 1.8 it works fine to compile, but when I try to compile in 1.7 it doesn't work.
I know the short answer is to update the linux to JRE 8. But I am curious, is there a way to make it backwards compatible? Or is the other answer to simply install JDK7 on the desktop in order for it to run on the linux box using JRE7?
Java programs built with JDK 8 will only run on machines running JRE 8 (or higher).
I found this when trying to compile classes on my local Linux machine (using JDK 8) and deploying to a remote server running JRE 7. The classes just wouldn't work (like you're finding).
If you want to use JRE 8 on linux, I recommend using the oracle-java8-installer package from webupd8team. Installation instructions found here (assuming Debian based distro).
If you want to compile to JDK 7, it's not good enough to only have JDK 8 installed and pick to compile 1.7. You need JDK 7 installed to and restage your project to use JDK 7.
The thing you have to remember is that the difference between JRE/JDK versions is not just the extra features developers can use (e.g Lambda functions) but it's also that the JRE itself is improved (efficiency, garbage collection, etc.).
As a extreme example: If you wrote code that only used JDK 1 features but compiled it using JDK 8, it wouldn't run on a machine running JRE 1 because the Java classes had been compiled with JRE 8 in mind.
Do note though, that if you're Java Code uses only features from JDK 7 or 6 etc., you might think it good practice to compile using the minimum JDK required to allow for compatibility with more machines. Well...you'd have that compatibility but at a cost of using inefficient, out of date, possibly vulnerable compiled classes (At little extreme, but you get my point).
Are you using any new Java 8 features? Because if you are, this means you cannot build the project against the JRE7.
If you are not using any Java 8 features, you can build to Java 7 most easily by downloading the JDK7 and switching the project to use that instead of the JDK8.
You should also set project language level to 1.7 (and module language level(s) as well, if they're different). It's done in Project Structure settings dialog. After that the project should compile.
Note that you shouldn't use any of the APIs that appeared in 1.8, but such usages will most likely be highlighted in the editor.

which java version need to be uninstall

I already researched on how to install Eclipse Luna. One of the things to consider before installing Eclipse is to choose the JDK (planning to use JDK 8). It said that it is recommend that if I have an older version of Java, I need to uninstall it. But here's the problem: I don't know which I should uninstall. Here is the list of installed versions in my control panel (Windows 7 64bit):
Java 7
Java(TM) 6 Update 45
Java(TM) SE development kit 6 (i think this one but what's with (TM)?)
It is strongly recommended to specify what JVM (preferably a JDK) Eclipse should run in, via the eclipse.ini file. That way you can have any number of JDKs and/or JREs without problem. In fact, Eclipse also allows you to have multiple Java versions on your machine and each project in Eclipse can dictate exactly which one it uses. You can easily mix-and-match projects that use different Java versions, and they're all independent of the JVM that Eclipse itself is running in.
run java -version at the command line to see which one is in your PATH. This is the one that will run the Eclipse workspace.
Unless you have clear requirements to use older Java versions, I would recommend to uninstall all of them. And just have the latest JRE or better JDK installed.
In my case, I have a JRE to run the Eclipse workspace that is maintained by the Admin people and a private JDK (to provide additional tools, such as javadoc) to support the software development. You can have several Java versions installed (without having them in the PATH environment listed). You can point to them in the workspace settings or in specific Eclipse projects, e.g., to use a Java 6 for a certain project.
I think Eclipse Luna needs Java 7.
A Java 7 JRE/JDK is required for most of the Luna package downloads based on Eclipse 4.4.
In my opinion you can uninstall Java(TM) 6 Update 45 & Java(TM) SE development kit 6

Categories