Java classpath still the same after changing .bashrc - java

Is there a clear instruction available on how to set the classpath properly for updating the java jdk and the java vm?
On my system is Java 1.7 installed but I need the features of Java 8!
So I did the following steps as mentioned in the official Oracle classpath guide and other tutorials but it just doesn't work for me:
1.) moved the jdk to /usr/lib
2.) added the following lines to the ~/.bashrc:
PATH=/usr/lib/jdk1.8.0_60/bin:$PATH
export PATH
I type which java
Output is /usr/bin/java which is still the old 1.7 jdk
The runtime (VM) is not the official form Oracle but the openJDK so I also need to update this one to version 8...

Related

How can I change Java version 1.7 to 1.8 in Ubuntu?

My Ubuntu machine have installed both java 1.7 and 1.8. But when I checked Java version it shows version Java 1.7 as the snapshot below. When I check Java alternative version I can see "java-8-openjdk-amd64". I am beginner to Ubuntu. Can anyone help me to change it to 1.8?
sdkman is a good Open source version manager for Java. It provides commands to search & install multiple versions of Java and switch between versions with
sdk use java 1.8.363-open
It can also manage other tools like Maven.
you can set the envirnoment variable to java 1.8
using this method
Edit the /etc/profile
sudo gedit /etc/profile
Add these lines in the end
JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java
PATH=$PATH:$HOME/bin:$JAVA_HOME/bin
export JAVA_HOME
export JRE_HOME
export PATH
like mentioned in this answer
How to set Java environment path in Ubuntu

Why does the Java JDK not set its own path after installation on Windows?

Problem:
After installing Java SE version 14.0.1 I tried to run the command java in CMD because I wanted to check if everything works as it should, but an error occurred because CMD could not find what I wanted.
I checked the system environment variable to see if the path for the Java JDK was set, but no, it was not set.
Question:
Why was the path not set by the Java JDK after installing Java SE 14.0.1?
It depens on the installator provider by the combianation of vendor and version. As far as I know the AdoptOpenJDK add the PATH variable

Set custom Java version for CMake

I am trying to install a Tool (SciDB); its installing procedure makes use of CMake. At a certain point it requires Java 1.8, which is not installed on the system.
-- Could NOT find Java (missing: Java_JAVA_EXECUTABLE Java_JAR_EXECUTABLE Java_JAVAC_EXECUTABLE Java_JAVAH_EXECUTABLE Java_JAVADOC_EXECUTABLE)
CMake Error at src/jdbc/CMakeLists.txt:5 (message):
Java 1.8 is currently the only supported version for building JDBC!
I installed it somewhere in my home folder; how to tell CMake to use my version?
I tried to set the $JAVA_HOME and $PATH variable as suggested in this previous answer, but got no results.
SciDB uses its own version of FindJava.cmake (located in cmake/Modules/FindJava.cmake). SciDB expects a particular environment and that the user has installed OpenJDK version 1.8.
One way to use your JAVA_HOME is to modify cmake/Modules/FindJava.cmake in your source code and add your ${JAVA_HOME}/bin:
set(_JAVA_PATHS
$ENV{JAVA_HOME}/bin
/usr/lib/jvm/java-1.8.0-openjdk/bin
/usr/lib/jvm/java-1.8.0-openjdk-amd64/bin
/usr/lib/jvm/java-1.8.0-openjdk.x86_64/bin
)
NOTE: The version of Java in that $JAVA_HOME will NOT be checked.

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.

java enum in different versions and updations

I am using jre 6 now. Earlier, I was using javasdk1.4 but as I searched in Internet, found that enum is supported in 1.5 or higher version. So, I first updated jre to latest version and then now how to update j2sdk1.4 .
When I am using echo %PATH%
path showed is "C:\Program Files\Java\jre7\bin"
But I can't set path to this location as 'javac' here is not recognizable..
My enum code i am not posting but is verified that it is correct.. Here, I am facing problem of setting path and updating j2sdk 1.4 even after jre updated to latest Version.
Note: I want to set path using command-prompt and Path command not using environment Variable.
I am using windows Xp
javac is not included in the JRE, it's just a runtime environment (Java Runtime Environment) used to run Java applications, nothing more.
Download a JDK (Java Development Kit) instead.

Categories