On Fedora I installed (or at least tried to install) JDK-18. I rebooted my laptop and wanted to check if it succeeded. I used java --version, but it said bash : java : command not found.
Well all that I will write is subjective. It all depends upon how did you install java in Fedora. If you downloaded the jdk distribution and unzipped it to some folder. Then in your .bashrc, you need to provide the path where the binaries are available
export PATH=$PATH:/path/to/java/installation/folder/bin
You can also look at sdkman
https://sdkman.io/
This is a nice tool to manage your JDK(s) regardless of Linux distribution you are using. (disclaimer: I have no affiliation with sdkman - i find this tool very helpful)
Due to this issue, at the moment Cordova isn't able to run on Java 9 (please correct me if I'm wrong).
A similar question was discussed here, but the proposed solutions involve the removal of Java 9, or the reset of the JAVA_HOME environment variable to point to Java 8, but both has the side effect that all the other Java applications will run on Java 8.
So how do you set Cordova to use Java 8, having the rest of applications still on Java 9?
... the reset of the JAVA_HOME environment variable to point to Java 8, but [that] has the side effect that all the other Java applications will run on Java 8.
Only if you do it the wrong way!
Create a file (say mycordova.sh) containing this, make it executable and put it on your shell's command search path.
#!/bin/sh
export JAVA_HOME=/path/to/java8/home
cordova "$#"
Running that command runs cordova using Java 8 without interfering with other applications.
UPDATE - If the work-around proposed is to use alternatives to change, that means that the cordova launcher / script, is not using JAVA_HOME to find the java command. You can deal with that too. There are a couple of possibilities:
If cordova is a wrapper script, then copy it and edit it to use the version of the java command (etc) that you want to use.
If not then in your mycordova.sh script (see above) also update the PATH variable so that the Java 8 JRE's bin directory is ahead of the directory containing the java link that alternatives manages. That will work ... provided that the standard cordova launcher has not hard wired /usr/bin/java
UPDATE 2 - Final script for mycordova.sh is:
#!/bin/sh
export JAVA_HOME=/path/to/java8/home
export PATH=/path/to/java8/bin/:$PATH
cordova "$#"
We have provisioned a RHEL server from Azure. I understand that our infrastructure guys are a bit strict on access.
We need to install Oracle JDK in this machine and it looks like wget is not an option on getting rpms, only yum. However, I need to enable Third-party repo like Oracle in order to yum install a JDK, so I issued this command:
subscription-manager repos --enable rhel-7-server-thirdparty-oracle-java-rpms
and I get
Network error, unable to connect to server. Please see /var/log/rhsm/rhsm.log for more information
When I do yum update and yum install telnet, it seems to do its job.
My question is, do I have an alternative in getting JDK installed? For those who are knowledgeable about Azure and networking configuration, what specific request should we ask from our infrastructure people to enable "download"?
Per my experience, i think the issue may be caused by the VM network. But, this has not problems when you run yum update. So i suggest that you can run ping www.microsoft.com in the VM terminal to inspect whether your VM can connect to extranet.
For your first question, we can use an alternative method to install oracle JDK on RHEL.
1.You could download the Oracle JDK(.tar.gz) from Oracle official website just as below.
http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html
2.You could upload JDK package which you have downloaded to your Azure VM directory by ftp tools like FileZilla.
description image
3.You could use SecureCRT to connect to Azure VM.
description image
4.
Install java with alternatives.
#cd /home/johnny
#tar -zxf jdk-7u79-linux-x64.tar.gz -C /opt/
#cd /opt/jdk1.7.0_79/
#alternatives --install /usr/bin/java java /opt/jdk1.7.0_79/bin/java 2
#alternatives --config java
the output may be below:
description image.
you could input 1 to continue.
5.Now, you may also require to set up javac and jar commands path using alternative commands.
#alternatives --install /usr/bin/jar jar /opt/jdk1.7.0_79/bin/jar 2
#alternatives --install /usr/bin/javac javac /opt/jdk1.7.0_79/bin/javac 2
#alternatives --set jar /opt/jdk1.7.0_79/bin/jar
#alternatives --set javac /opt/jdk1.7.0_79/bin/javac
6. Check installed java version.
#java -version
description image
7.Configuring environment variables.
Setup JAVA HOME variable:
#export JAVA_HOME= /opt/jdk1.7.0_79
Setup JRE HOME variable:
#export JRE_HOME=/opt/jdk1.7.0_79/jre
Setup PATH variable:
#export PATH=$PATH:/opt/jdk1.7.0_79/bin:/opt/jdk1.7.0_79/jre/bin
There is another method to config environment variables.
Modify the config file: /etc/profile. In this method, anyone who has logged in can use java.
description image
8.The refference:
http://tecadmin.net/steps-to-install-java-on-centos-5-6-or-rhel-5-6/#
For your second question, you can ask some problems about azure network config.
Hope it helps. Any concerns, please feel free to let me know.
I am trying to install a software on CentOS and the doc says something like this...
If you are using a Linux distribution
that installs GCJ by default (which
includes all of the most popular
distros), then before you begin
installation you must remove, disable,
or circumvent GCJ. If you cannot
remove it, you can simply ensure that
your JAVA_HOME variable is properly
set, and add the Java Runtime
Environment's /bin/ directory to the
beginning of your PATH variable in
~/.bashrc or /etc/environment, then
relog before continuing.
I will like to know the exact commands I need to execute to that effect.
(Java Newbie)
After you've installed for example the Oracle JDK then you can use the following command:
alternatives --config java. This command has to be performed as root user.
Is there Ruby Version Manager equivalent for the Java world?
I'm looking for tool which allow me to easily download and install a new JVMs and switch between them. For example:
jvm install <version>
jvm list //will list installed JVMs on my system
jvm use jdk1.6 //will switch my env to jdk 1.6 version, etc.
http://www.jenv.be/ will allow this type of control.
SDKMAN! is a similar tool for the Java ecosystem. Supports various Java versions, Scala, Clojure, Kotlin, Groovy, and build tools like Maven and Gradle.
Works on Mac and Linux, with some mentions of support for Windows depending on how hard you are willing to try :)
If you use Ubuntu you can specify which JVM you want to use via command (works only for JVM installed from apt-get or aptitude)
sudo update-alternatives --config java
Or by setting JAVA_HOME. Here is good tutorial:
http://vietpad.sourceforge.net/javaonlinux.html
For the sake of completeness, there are two more - jabba (of which I am the author; written in Go and designed after nvm/gvm/rvm) and jenv (not to confuse with jenv.be; doesn't support installation from oracle but can install from a custom zip).
With JVMs, if you need to switch between them you just need to use a batch file (or powershell script) to manage the classpath and JVM path. You don't need to rely on the system default JVM path and instead just allow your app to point to whatever JVM you like by changing classpath and JVM path environment in the shell that runs the JVM.
For programs that are getting Java location from the Registry, in theory you could use a batch script to update that also.
In this respect Java is way easier than "Ruby version manager".
As it is not (yet) in the list of possibilities, there's also asdf.
asdf does not only provide version management for java, it has plugins for ~400 different languages and tools by default, you can find more on github, or create your own.
Here is an example how to setup a new install (you can also install completion so you don't have to list the versions first). The java plugin is added, a specific version (there are versions for adoptopenjdk, corretto, dragonwell, graalvm, liberica, mandrel, microsoft, openjdk, oracle, sapmachine, semeru, temurin, trava, zulu) is installed and configured to be the global (or local version) to use:
asdf plugin-add java # Add java Plugin
asdf list-all java # List all available java versions
asdf install java openjdk-18 # Install specific jdk version
asdf install java openjdk-17 # Install another jdk version
asdf global java openjdk-18 # Set the global jdk version
asdf local java openjdk-17 # Set the local version for calls from the current directory
asdf uses a file in $HOME/.tool-versions to configure the global selected version. If you call any tool in a directory that has a .tool-versions file with a different version, that one is used (defined with asdf local …).
The trick is to use update-java-alternatives (from the java-common package). The update-alternatives command will not update every one of the symbolic links for various java /bin executables, which is why update-java-alternatives is better.
So to go for OpenJDK 6 to 7, use update-java-alternatives -l to get a list of Java alternatives and then used sudo update-java-alternatives -s java-1.7.0-openjdk-amd64 to switch the JDK.
CAVEAT: The command above might throw the following errors,
update-alternatives: error: no alternatives for mozilla-javaplugin.so.
update-java-alternatives: plugin alternative does not exist:
/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/amd64/IcedTeaPlugin.so
This is because the openjdk plugin is not installed by default. To fix run sudo apt-get install icedtea-7-plugin and rerun update-java-alternatives.