Sanity check: correctly downgrading Java in conda environment - java

I want to downgrade from Java 10 to Java 7 for one of my conda environments. I created a copy of an old environment, and now want to downgrade the Java version. Originally I was hoping I could do something like:
conda create --name new-env --clone old-env java=1.7
But that's not possible. Instead, I think I'm supposed to download Java 1.7 and then just change the JAVA_HOME environment variable in my new environment. Is this correct?
Thanks for your help!

Related

Mac OS. No recognized OpenJDK

At first we are talking about MacOS Big Sur.
Until today I had the folder jdk-16.0.2.jdk with all its content in /Library/Java/JavaVirtualMachines which I downloaded from Oracle at a certain point in time.
It worked fine and java -version respondeds with the corresponding version and Netbeans worked fine along with Tomcat.
That was my java installation. Downloaded the .tar from Oracle and copy to that folder.
Today I am trying to migrate to openJDK so I did the same. I downloaded "openjdk-17.0.2_macos-aarch64_bin.tar" from java.net. Just the same procedure. Untar the files and copy to /Library/Java/JavaVirtualMachines (And moving the old Java to Desktop.
When I try % java -version I get:
The operation couldn’t be completed. Unable to locate a Java Runtime.
Please visit http://www.java.com for information on installing Java.
I resist a little to the idea of installing JAVA via homebrew (Which I use for other purposes) since I'd like to have the very same version in my dev environment (My Mac in this case) and in my production environment (Rocky Linux 8).
Any idea?
Thank you very much in advance.
If you have not yet updated your %JAVA_HOME% environment variable, that must be pointed to your new installation. Your installation path looks correct. Here is a thread about setting the environment variable: https://stackoverflow.com/a/65162351/1656012

Not able to set JAVA_HOME

I have 3 installed versions of java (1.6,1.7,1.8) in my machine. Java alternatives has been configured to Java 1.8. So whenever i type java -version it is picking up from alternatives and showing java 1.8.
Here now i want to use other version of java (1.6 or 1.7), for that i have tried updating the .bashrc with other java paths. But still it is showing alternatives version (1.8)
Is there any way to override alternatives java from user level.
Here is a blogpost explaining how to change jdk version in a *nix environment from terminal:
https://www.jayway.com/2014/01/15/how-to-switch-jdk-version-on-mac-os-x-maverick/
There is no need to change your environment to switch Java version.
You can simply qualify the version you want to use. Alternatively, just make sure the version you want is first on the PATH, not last.
See my old answer for examples. It's for Windows, but it should work similarly for Linux.
https://stackoverflow.com/a/32365879/5221149
Found the fix
I did like below
export PATH:new_java_path:$PATH. Now it started working for the current session.

How can I change java version on local linux server

I built my NetBeans web project with Java 1.5 successfully, however; my linux server supports / uses Java 1.4 and Java 1.5 (as well as JBoss 4.0.2).
When I check the version of my project ( java -version ) it says that the current version is Java 1.4.2. However, I don't want to change the "JAVA_HOME" setting on the server because other projects need to use this version.
I want my project to use Java 1.5 from the server...
An idea as to how I should go about doing this? Is there a configuration that I can change?
I have this error:
java.lang.UnsoupportedClassVersionError: bad Version in .class file
You need Java 1.5 version installed in your Linux server.
Next, run the following set of commands in your terminal/command prompt:
JAVA_HOME="{fix-me}"
export JAVA_HOME
export PATH = $JAVA_HOME/bin:$PATH
In the place holder {fix-me} specify the path of Java 5 that is installed in the Linux machine.
This would only temporarily set the Java version to 5 until the terminal/command prompt session is alive. So you need not worry about disturbing other projects.

Confusion about Java Versions

So I'm trying to get the latest version of Java. When I run:
java -version
I get:
java version "1.6.0_65"
Java(TM) SE Runtime Environment (build 1.6.0_65-b14-462-11M4609)
Java HotSpot(TM) 64-Bit Server VM (build 20.65-b04-462, mixed mode)
When I run:
javac -version
I get:
javac 1.6.0_65
Now I've just downloaded and installed JDK 8. When I go into System Preferences --> Java --> Update, I see:
Your system has the recommended vesion of Java.
Java 8 Update 05.
I guess I have a few questions:
1) Don't I want the JDK and my version of Java to match up?
2) Why does my Java Control Panel claim I have Java 8, but my work in the terminal (when checking my Java version) says otherwise?
Thanks for the help,
Mariogs
The probably "simple" answer is you have two versions of java installed. On the command line you currently use 1.6. Thus the old one is active. In system preferences you see the version of java 8.
Windows:
You can change the version of the command line to java 8. Set PATH environment variable and JAVA_HOME or via windows preferences. I recommend the first one.
Mac: /usr/libexec/java_home is the starting point for switching java versions on the command line. Check out this post to understand how to handle different java versions on the Mac. IMHO this answer is a good solution.
The Java Platform offers both the JRE and the JDK in order for users to run Java programs. The JRE stands for the Java Runtime Environment, and the JDK stands for the Java Development Kit.
The JDK is meant for Java developers - that is, those who build applications/write programs in Java. It contains tools that are needed for Java coding, including -javac to compile programs.
The JRE is meant for regular users - those who only need to run Java programs on their computer and are not interested in development.
The reason for the discrepancy in your case is because you're looking at the JRE and JDK and trying to compare the two. The current JDK that you have is Java 8, whereas the current JRE that you have is 1.6.0_65. It is problematic that your JRE version does not match your JDK version, but without your PATH variable or other information about your install, we can't help you fix your installation.
1) Yes, if you use the JDK at all, you want the JRE (runtime environment) to come from the JDK (development environment) (a JDK necessarily includes a JRE).
2) Likely your path variable is set so that you invoke Java from your Java 6 installation; you need to find the equivalent for your Java 8 installation and set the path for that. Without information about your operating system, we can't help you do that.
We should know the reason for this
Our OS comes with a predefined (built-in)set of tools and utilities. When we try to execute the command e.g. cls in the Windows command line then it is already present in system path variable and os will refer the corresponding binary of cls to execute the command.
However, when we install any third party tool/software then path variable is not updated accordingly.
When we install different versions of java on your system then installations go to different directories. E.g. JDK installation directory for Windows will be
C:\Program Files\Java\jdk1.8.0_161
Similarly, JRE installation directory for Windows will be JDK installation directory for Windows will be
C:\Program Files\Java\jre1.8.0_161
We need to update the path variable of OS to point to the appropriate directory. If we set the path of JDK then it will execute a binary from JDK bin directory.
Solution
we need to update JDK or JRE version specific directory location into PATH Environment variable.
Let me see if I can clear it up for you.
1)Yes, arguably you nearly want this to be true.
2)It could be few things, but most likely that a previous instillation was not properly removed. So one gets called instead of the other.

Mint Linux - Downgrade Java to 1.5

Currently, I am running Mint Linux (Release 9). I need to downgrade Java from version 1.6 to 1.5, and have been trying to figure out how to go about this. So far, I've had no luck. The package manager doesn't seem to have it.
Does anyone have any suggestions?
Thanks,
- Chris
As you explained in your comments, you need JDK 5 because you are working on the source code of Android itself and the instructions say:
Ubuntu Linux (64-bit x86)
... JDK 5.0, update 12 or higher.Java 6 is not supported, because of incompatibilities with #Override.
You can do this:
Uninstall any Java that you got via the package system of your Linux distro
Download JDK 5 Update 22 for Linux
Run the JDK installer with sudo, install it wherever you like (for example in /opt or /usr/local)
Set your PATH environment variable to include the bin directory of the JDK
There should be no need to downgrade your Java installation to develop for Java 1.5. If you are using a tool such as Eclipse, you can set the project attributes so that it tests for Java 1.5 compatibility, and gives errors if you use a Java 6 feature. If you absolutely insist on having a Java 1.5 JDK then just install it alongside the default installation and use it in place of Java 1.6.
This should be a question for SuperUser.com, but my recommendation is to download the 1.5 JDK, and change Java path to where you downloaded it.
Or you could use the info on Ubuntu Help, it should work for you since Mint is based on Ubuntu. That link explains how to select the version of Java.

Categories