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.
Related
When I tried to install Hive through homebrew it throws below error:
homebrew install hive
Error: openjdk#8: no bottle available!
Has anyone solved this issue?
I did a bit of research in google and someone said "this is because the M1 chip needs it's own special version of OpenJDK ".
Apple silicone M1 and similar processors have the ARMv8.4 architecture and rosetta2 to launch native amd64 binaries on the arm64 processor. So apple silicone may launch nearly any app compiled for the Intel platform (there is some exception, for example, the older version of PostgreSQL won't be launched by rosetta2).
By default, homebrew detects the platform that is installed and tries to find the bottle that is appropriate for arm64. In some cases, there is no bottle for some applications (for example, you can't install openjdk#8 on arm64 because there is no bottle). But you can install, for example, oracle JDK because there is the bottle for arm64 (but it will install amd64 binaries). It is a pretty confusing situation, isn't it?
The decision is to install the second copy of homebrew into the /usr/local/homebrew directory and launch it in compatibility mode with the command arch -x86_64. You won't start the original homebrew with this command because it will lid to mix arm64 and amd64 binaries (and what you will do, if you need the same library for both platforms? libpq as an example).
So there is the step-by-step guide:
Download homebrew curl -L https://github.com/Homebrew/brew/tarball/master --output homebrew.tar
Extract tarball to /usr/local/homebrew
chown -R to allow start apps from this folder
Add aliases to your ~/.zshrc file
# If you come from bash you might have to change your $PATH.
# need this for x86_64 brew
export PATH=$HOME/bin:/usr/local/bin:$PATH
# for intel x86_64 brew
alias axbrew='arch -x86_64 /usr/local/homebrew/bin/brew'
Now start new console and launch installation, for example axbrew install openjdk#8
Install other Intel binaries you need the same way. Remember that it will be installed into the /usr/local/homebrew/ directory - fill free to create a symlink if you wanna use it something else.
The slight disadvantage - the java_version tool won't see the OpenJDK in /user/local directory, but symlink to /Library/Java/JavaVirtualMachines/ will solve this problem.
Finally, I found a solution. First, We need to install Homebrew with Rosetta under /usr/local and then we can try installing everything the same way.
Combine Gleb Yan's answer and another website's solution https://github.com/Homebrew/discussions/discussions/2723. What I do is
arch -x86_64 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Then run
arch -x86_64 /usr/local/homebrew/bin/brew install openjdk#8
Then
arch -x86_64 /usr/local/homebrew/bin/brew install hive
Reminder two separate Homebrew hierarchies on your machine, an Intel-only one under /usr/local, and an M1-only one under /opt/homebrew
I am trying to install the latest version of Java in my Linux machine, but I am unable to do so.
Steps I followed:
Downloaded the latest Java tar ball.
Copied into /usr/lib/jvm and untared it.
Adding in to environment variable (export JAVA_HOME=/usr/lib/javm/jdk1.7.0_80, export PATH=$PATH:$JAVA_HOME/bin).
When I try to change the default Java version, the installed one is
not coming ($ update-alternatives –-config java).
How do I resolve this? I have followed many links, but nothing helps.
You will also have to "install" the new Java software to /etc/alternatives/, in order to select it:
sudo update-alternatives --install /usr/bin/java java /usr/lib/javm/jdk1.7.0_80/jre/bin/java 2000
I am starting a Windows Server AMI and would need to have java 8 installed after boot. I already have an instance-setup.txt script to install the codedeploy-agent automatically (from here: http://docs.aws.amazon.com/codedeploy/latest/userguide/how-to-set-up-new-instance.html), but would need to install Java 8 at the same time. I have no idea how to automatize this though, did anyone manage to do it successfully by any chance ?
Thanks !
Emmanuel
The Java installers for Windows provide the ability to run an installation in silent mode via the command line or a script. If you package a Java installation executable with your deployment you can run a silent install like this:
jre-8-windows-i586.exe /s
Check out the documentation on Windows Installer Options for Java for more information and other available options: http://docs.oracle.com/javase/8/docs/technotes/guides/install/windows_installer_options.html
I have to automate a process in which i need to install java on RHEL 7, using rpm package and then update the security jars later on the installed location. Once i execute the java rpm, how would i get the correct installed path? when i execute which java it says /bin/java. However, i need the installation location using shell script.
Here, the actual installation happened at /usr/java/jdk1.7.0_55/jre. I want to get this location. Can some one suggest me how to retrieve this?
The readlink program (part of coreutils, and available on any RHEL version) can resolve symbolic links:
foo=$(readlink -f $(which java))
echo $foo
(You may also have realpath, but perhaps not).
Java RPM packages from Oracle support the 'alternatives' system, which provides the detail you are seeking. For example, after installing a recent JRE, 'alternatives' reports like so:
[user#host ~]$ alternatives --display java
java - status is auto.
link currently points to /usr/java/jre1.8.0_60/bin/java
etc...
The output is relatively friendly for scripting.
Trying to install Java (JDK 6) on my new Ubuntu system and getting some bizarro errors. This is my first time ever using any flavor of Linux and so I'm sure it's a user issue (permissions or otherwise).
I downloaded the BIN file directly off Oracle's site (Java SE 6u23 for 64-bit Linux). This defaulted to downloading to /home/myUserName/Downloads.
From there I moved the file to /opt/java, which was a directory I created, because (as a Linux novice) that made sense to be the directory where Java should go.
I then ran the following 2 commands, per instruction I found online for running BINs:
chmod +x jdk-6u23-linux-x64.bin
sudo ./jdk-6u23-linux-x64.bin
Now, in my /opt/java directory I see both the BIN file and the jdk1.6.0_23 directory that seems to be intact upon inspection.
But, when I open a new terminal and run java -version, I get:
The program 'java' can be found in the following packages:
- gcj-4.4-jre-headless
- gcj-4.5-jre-headless
- openjdk-6-jre-headless
Try: sudo apt-get install
What is going on here?!?
(1) Was I wrong to try and make /opt/java my Java directory?
(2) Did I run the wrong commands?
(3) Is Java 1.6.0_23 even installed on my machine?
(4) What are all those gcj-xxx-headless targets?!?!
Thanks for any input!
Was I wrong to try and make /opt/java my Java directory?
Not really. Many Java developers install multiple JDK installations and always use /opt/jdk1.6.0_23 or similar paths. The bin file you downloaded is not an installer, but merely an extractor. It does not install the java binaries into system folders like /bin.
I usually download the JDK and execute it from within my home folder and afterwards move it to /opt and performing an chown.
Did I run the wrong commands?
Not really. In case you wanted to install a separate JDK, you did it correctly. In case you wanted system integration, you would be better off to use the distribution-specific packages, such as the one installed via aptitude install sun-java6-jdk or alike.
The bin you downloaded is imho more flexible, since I can use it to install multiple verisons of Java on the same system. I know this is something you don't often do on Linux machines.
If you want to use the java binary on command line, you'd have to manually set up the PATH and JAVA_HOME environment variables. I think on Ubuntu that's /etc/environment or /etc/profile or something like that.
Is Java 1.6.0_23 even installed on my machine?
Not really. See above answers.
What are all those gcj-xxx-headless targets?!?
The GCJ is the Gnu Compiler for Java. Obviously, it includes a Java Development Kit and a Java Runtime Environment.
Why downloading a bin, when you can simply:
sudo apt-get install sun-java6-jdk
If there isn't any special reason why you'd want that specific version from the site, you should use apt-get because it will take care of all the stuff like PATH variable, etc.
Please follow below steps to install oracle java:
Download the latest Java SE SDK version.
http://www.oracle.com/technetwork/java/javase/downloads/index.html
Untar the Archive:
tar -xzvf jdk-8-linux-x64.tar.gz
mv jdk1.8.0 /opt
cd /opt/jdk1.8.0
This step registers the downloaded version of Java as an alternative, and switches it to be used as the default:
update-alternatives --install /usr/bin/java java /opt/jdk1.8.0/bin/java 1
update-alternatives --install /usr/bin/javac javac /opt/jdk1.8.0/bin/javac 1
update-alternatives --install /usr/lib/mozilla/plugins/libjavaplugin.so mozilla-javaplugin.so /opt/jdk1.8.0/jre/lib/amd64/libnpjp2.so 1
update-alternatives --set java /opt/jdk1.8.0/bin/java
update-alternatives --set javac /opt/jdk1.8.0/bin/javac
update-alternatives --set mozilla-javaplugin.so /opt/jdk1.8.0/jre/lib/amd64/libnpjp2.so
Test
To check the version of Java you are now running
java -version
Output
java version "1.8.0"
Java(TM) SE Runtime Environment (build 1.8.0-b132)
Java HotSpot(TM) 64-Bit Server VM (build 25.0-b70, mixed mode)
To check the browser plugin browse to http://www.java.com/ and click “Do I have Java?”
Ref: https://askubuntu.com/questions/437776/ubuntu-13-04-unable-to-install-jdk7
You simply have put the JDK binaries in a directory. Although by convention /opt/java or /opt/jdk is often used, these are not directories that are automatically recognized by the system.
You can however update your PATH environment variable to include the /opt/java/bin dir, or symlink (ln -s) /opt/java/bin/java in one of the directories on your system that are included in your path like /usr/bin/
The JDK you installed from Sun/Oracle is the original JDK. The "headless" JDK is the open source alternative.
When you run the JDK BIN file, it simply extracts the archive. When you entered the java -version command, it found the FOSS Java, not the Java you had extracted in /opt. As somebody else had mentioned, developers keep multiple versions of the JDK. If you wish to use the Oracle's Java, then you need link /usr/bin/java to /opt/jdk1.6.0_23/bin/java.
sudo ln -s /usr/bin/java /opt/jdk1.6.0_23/bin/java
For this to work, the existing java command should be first delinked from the "headless" JDK. (Do the following before the previous command.)
sudo mv /usr/bin/java /usr/bin/java_old
This assumes that there is a link or executable named java in /usr/bin. Use the which command to be sure.
which java
To add a new pathname to the existing PATH variable, you need to type this in Terminal:
PATH=`echo $path`:/your/new/path
export PATH
If you had lost your original PATH variable, you could restore by entering this:
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
export PATH
Try:
rm -rf /usr/bin/javac
rm -rf /usr/bin/jar
ln -s /home/jdk1.6.0_13/bin/javac /usr/bin/javac
ln -s /home/jdk1.6.0_13/bin/jar /usr/bin/jar
This way, your linux can find java && javac in /usr/bin