Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 8 years ago.
Improve this question
The java version on the server was 1.6.0_37, I used yum install java-1.7.0-openjdk to install Java-1.7 but after using this command when I used java -version the version of Java is still 1.6.0. How to change it to 1.7?
# yum install java-1.7.0-openjdk
java -version
java version "1.6.0_37"
Java(TM) SE Runtime Environment (build 1.6.0_37-b06)
Java HotSpot(TM) 64-Bit Server VM (build 20.12-b01, mixed mode)
I also followed following steps but java version is still 1.6.0_37
Downloading Latest Java Archive
Java latest archive is available on its official site. We recommend to download latest version of Java from Oracle official website.
For 64 Bit:-
# cd /opt/
# wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/7u75-b13/jdk-7u75-linux-x64.tar.gz"
For 32 Bit:-
# cd /opt/
# wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/7u75-b13/jdk-7u75-linux-i586.tar.gz"
Note: In any case if above command failed to download and you need to download java through Linux terminal, watch below screen cast ( http://screencast.com/t/wf9bQ0XjDPxT ), You are required a graphical browser.
After completing download, Extract archive using following command. Use archive file as per your system configuration. For this example we are using CentOS 6.6 (64 bit) system.
# tar xzf jdk-7u75-linux-x64.tar.gz
Install Java with Alternatives
After extracting Java archive file, we just need to set up to use newer version of Java using alternatives. Use the following commands to do it.
# cd /opt/jdk1.7.0_75/
# alternatives --install /usr/bin/java java /opt/jdk1.7.0_75/bin/java 2
# alternatives --config java
There are 4 programs which provide 'java'.
Selection Command
-----------------------------------------------
* 1 /usr/lib/jvm/jre-1.6.0-openjdk/bin/java
+ 2 /opt/jdk1.7.0_60/bin/java
3 /opt/jdk1.7.0_72/bin/java
4 /opt/jdk1.7.0_75/bin/java
Enter to keep the current selection[+], or type selection number: 4 [Press Enter]
Now you may also required to set up javac and jar commands path using alternatives command.
# alternatives --install /usr/bin/jar jar /opt/jdk1.7.0_75/bin/jar 2
# alternatives --install /usr/bin/javac javac /opt/jdk1.7.0_75/bin/javac 2
# alternatives --set jar /opt/jdk1.7.0_75/bin/jar
# alternatives --set javac /opt/jdk1.7.0_75/bin/javac
Check Installed Java Version
Use following command to check which version of Java is currently being used by system.
# java -version
java version "1.7.0_75"
Java(TM) SE Runtime Environment (build 1.7.0_75-b13)
Java HotSpot(TM) 64-Bit Server VM (build 24.75-b04, mixed mode)
Configuring Environment Variables
Most of Java based application’s uses environment variables to work. Use following commands to set up these variable properly. It’s also good to add following commands to any start-up script like ~/.bashrc or ~/.bash_profile.
Setup JAVA_HOME Variable
# export JAVA_HOME=/opt/jdk1.7.0_75
Setup JRE_HOME Variable
# export JRE_HOME=/opt/jdk1.7.0_75/jre
Setup PATH Variable
# export PATH=$PATH:/opt/jdk1.7.0_75/bin:/opt/jdk1.7.0_75/jre/bin
I also used following but still shows previous version
root#server [/]# yum search java | grep -i --color JDK
ldapjdk-javadoc.x86_64 : Javadoc for ldapjdk
icedtea-web.x86_64 : Additional Java components for OpenJDK - Java browser
java-1.6.0-openjdk.x86_64 : OpenJDK Runtime Environment
java-1.6.0-openjdk-demo.x86_64 : OpenJDK Demos
java-1.6.0-openjdk-devel.x86_64 : OpenJDK Development Environment
java-1.6.0-openjdk-javadoc.x86_64 : OpenJDK API Documentation
java-1.6.0-openjdk-src.x86_64 : OpenJDK Source Bundle
java-1.7.0-openjdk.x86_64 : OpenJDK Runtime Environment
java-1.7.0-openjdk-demo.x86_64 : OpenJDK Demos
java-1.7.0-openjdk-devel.x86_64 : OpenJDK Development Environment
java-1.7.0-openjdk-javadoc.noarch : OpenJDK API Documentation
java-1.7.0-openjdk-src.x86_64 : OpenJDK Source Bundle
java-1.8.0-openjdk.x86_64 : OpenJDK Runtime Environment
java-1.8.0-openjdk-demo.x86_64 : OpenJDK Demos
java-1.8.0-openjdk-devel.x86_64 : OpenJDK Development Environment
java-1.8.0-openjdk-headless.x86_64 : OpenJDK Runtime Environment
java-1.8.0-openjdk-javadoc.noarch : OpenJDK API Documentation
java-1.8.0-openjdk-src.x86_64 : OpenJDK Source Bundle
ldapjdk.x86_64 : The Mozilla LDAP Java SDK
root#server [/]# yum install java-1.7.0-openjdk java-1.7.0-openjdk-devel
Loaded plugins: fastestmirror
Setting up Install Process
Loading mirror speeds from cached hostfile
* base: centos.hyve.com
* extras: centos.hyve.com
* updates: centos.hyve.com
Package 1:java-1.7.0-openjdk-1.7.0.75-2.5.4.0.el6_6.x86_64 already installed and latest version
Resolving Dependencies
--> Running transaction check
---> Package java-1.7.0-openjdk-devel.x86_64 1:1.7.0.75-2.5.4.0.el6_6 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
================================================================================
Package Arch Version Repository
Size
================================================================================
Installing:
java-1.7.0-openjdk-devel x86_64 1:1.7.0.75-2.5.4.0.el6_6 updates 9.4 M
Transaction Summary
================================================================================
Install 1 Package(s)
Total download size: 9.4 M
Installed size: 36 M
Is this ok [y/N]: y
Downloading Packages:
java-1.7.0-openjdk-devel-1.7.0.75-2.5.4.0.el6_6.x86_64.r | 9.4 MB 00:03
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : 1:java-1.7.0-openjdk-devel-1.7.0.75-2.5.4.0.el6_6.x86_64 1/1
Verifying : 1:java-1.7.0-openjdk-devel-1.7.0.75-2.5.4.0.el6_6.x86_64 1/1
Installed:
java-1.7.0-openjdk-devel.x86_64 1:1.7.0.75-2.5.4.0.el6_6
Complete!
root#server [/]# ls -l /usr/lib/vim
/bin/ls: cannot access /usr/lib/vim: No such file or directory
root#server [/]# ls -l /usr/lib/jvm/
total 12
drwxr-xr-x 3 root root 4096 Feb 6 00:03 ./
drwxr-xr-x 28 root root 4096 Feb 5 22:47 ../
lrwxrwxrwx 1 root root 32 Feb 6 00:03 java-1.7.0 -> /etc/alternatives/java_sdk_1.7.0/
drwxr-xr-x 7 root root 4096 Feb 6 00:03 java-1.7.0-openjdk-1.7.0.75.x86_64/
lrwxrwxrwx 1 root root 34 Feb 6 00:03 java-1.7.0-openjdk.x86_64 -> java-1.7.0-openjdk-1.7.0.75.x86_64/
lrwxrwxrwx 1 root root 34 Feb 6 00:03 java-openjdk -> /etc/alternatives/java_sdk_openjdk/
lrwxrwxrwx 1 root root 21 Feb 5 23:52 jre -> /etc/alternatives/jre/
lrwxrwxrwx 1 root root 27 Feb 5 22:47 jre-1.7.0 -> /etc/alternatives/jre_1.7.0/
lrwxrwxrwx 1 root root 38 Feb 5 22:47 jre-1.7.0-openjdk.x86_64 -> java-1.7.0-openjdk-1.7.0.75.x86_64/jre/
lrwxrwxrwx 1 root root 29 Feb 5 22:47 jre-openjdk -> /etc/alternatives/jre_openjdk/
root#server [/]# vim .bashrc
root#server [/]# java -version
java version "1.6.0_37"
Java(TM) SE Runtime Environment (build 1.6.0_37-b06)
Java HotSpot(TM) 64-Bit Server VM (build 20.12-b01, mixed mode)
root#server [/]# cd $HOME
root#server [~]# vim .bashrc
Content of .bashrc
# .bashrc
# User specific aliases and functions
alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
export JAVA_HOME="/usr/lib/jvm/jre-1.7.0-openjdk.x86_64"
Currently the outpur of .bashrc is as following but same version of Java is still being used
# .bashrc
# User specific aliases and functions
alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
export JAVA_HOME="/usr/lib/jvm/jre-1.7.0-openjdk.x86_64"
export PATH=$PATH:$JAVA_HOME\bin
I usually install jdk to Linux and got the issue like yours.
I solve by editing ~/.bash_profile file:
JAVA_HOME=/opt/jdk1.7.0_75
#this should be point to your jdk directory
export JAVA_HOME
PATH=$JAVA_HOME/bin:$PATH
export PATH
Note: note that you put $JAVA_HOME/bin before $PATH when re-define PATH
Then, run below command to reload your .bash_profile file
. ~/.bash_profile
Then you can reopen your Terminal and check your Java version.
I achieved the same by appending the following contents to /etc/profile in CentOS 7. Also, I replaced my openjdk with Oracle's official JDK-8,but,that doesn't matter in actual sense here.
I suggest you to do the changes as I've done here in /etc/profile file. Replace the actual path/location depending on your system's location where java is installed :-
export JAVA_HOME=/usr/java/default
# point location before Java's bin folder in your system
export JRE_HOME=/usr/java/default/jre
# point location before JRE's bin folder in your system
export PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin
# append those 2 locations to the PATH environment variable
Where JAVA_HOME was the path upto installed Java's /bin directory as you can notice from the 1st export command above, JRE_HOME was the path upto JRE's /bin directory as you can notice from the 2nd export command above.
Related
I tried installing hadoop 2.7.3 on ubuntu 16.04 desktop.
I installed java and checked it's version as:
hadoop#ubuntu:~$ java -version
openjdk version "1.8.0_91"
OpenJDK Runtime Environment (build 1.8.0_91-8u91-b14-3ubuntu1~16.04.1-b14)
OpenJDK Server VM (build 25.91-b14, mixed mode)
I set JAVA_HOME in bashrc as:
#HADOOP VARIABLES START
export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-i386
export HADOOP_HOME=/home/hadoop/hadoop
export PATH=$PATH:$HADOOP_HOME/bin:$HADOOP_HOME/sbin
and executed:
$ source ~/.bashrc
then i edited the hadoop-env.sh as:
# The java implementation to use.
export JAVA_HOME="/usr/lib/jvm/java-1.8.0-openjdk-i386"
My java file location is:
then when i tried the command bin/hadoop it shows following error:
hadoop#ubuntu:~$ bin/hadoop
bash: bin/hadoop: No such file or directory
I don't know what to do.
These:
export HADOOP_HOME=/home/hadoop/hadoop
^^^^
hadoop#ubuntu:~$ bin/hadoop
^
You're in the ~ dir (home) directory, so effectively your command is
/home/hadoop/bin/hadoop
when it should be
/home/hadoop/hadoop/bin/hadoop
aka
$ hadoop/bin/hadoop
I am trying to use sdkman to manage versions of Groovy/etc on a Windows 7 box. All is fine when using a cygwin command prompt, but I want the Windows GROOVY_HOME set to the current. To do this, I have tried setting the CYGWIN environment variable to:
export CYGWIN=winsymlinks:native
export CYGWIN=winsymlinks
The CYGWIN doc seems to indicate that first method for defining links is appropriate, and that the second is more of a fallback. Changing the variable does indeed result in a different link - neither of which works in Windows 7.
The following is my current CYGWIN state.
[~]➔ echo $CYGWIN
winsymlinks
[~]➔ sdk default groovy 2.3.6
Default groovy version set to 2.3.6
[~]➔ groovy -version
Groovy Version: 2.3.6 JVM: 1.8.0_31 Vendor: Oracle Corporation OS: Windows 7
[~]➔ uname
CYGWIN_NT-6.1
[~]➔ uname -r
2.4.1(0.293/5/3)
Current Windows settings:
C:\Users\uc164033>echo %GROOVY_HOME%
C:\Users\uc164033\local\bin\cygwin64\home\uc164033\.sdkman\candidates\groovy\current
C:\Users\uc164033>cd %GROOVY_HOME%
The system cannot find the path specified.
C:\Users\uc164033\local\bin\cygwin64\home\uc164033\.sdkman\candidates\groovy>dir
Volume in drive C is OSDisk
Volume Serial Number is 7E0E-38C5
Directory of C:\Users\uc164033\local\bin\cygwin64\home\uc164033\.sdkman\candidates\groovy
03/29/2016 10:50 AM <DIR> .
03/29/2016 10:50 AM <DIR> ..
07/28/2014 03:28 PM <DIR> 2.3.6
07/09/2015 08:58 PM <DIR> 2.4.4
02/18/2016 10:16 PM <DIR> 2.4.6
03/29/2016 10:22 AM 1,285 current.lnk
1 File(s) 1,285 bytes
5 Dir(s) 896,974,188,544 bytes free
I can live with this as is, but sure would like to make my life simpler being that I cannot run on a Mac nor a Linux machine.
I just installed Netbeans using the script on Oracle's website and I'm having some trouble getting it to work. After opening Netbeans I went to open up a simple .java file just to test it out and got this error:
"The JDK is missing and is required to run some Neatbeans modules. Please use the --jdkhome command line option to specify a JDK installation or see http://wiki.netbeans.org/FaqRunningOnJre for more information."
I have OpenJDK, and I'm not sure what's meant by using the --jdkhome command line option. I also visited the wiki and it's about doing a full installation of JDK, which I don't think I should need to do. Any help is appreciated.
I think it's better to use Oracle Java JDK rather than Open JDK if you want to use Netbeans for java development
You can use this link to set Oracle Java JDK in Linux Mint
So, it's better to follow theses instructions (JDK install) prior to Netbeans install and all things will go well.
Steps:
1-Remove OpenJDK installation
sudo apt-get update && apt-get remove openjdk*
2- Download Oracle JDK you want to install (for example JDK 8)
Download the *.tar.gz one.
example for current version: jdk-8u65-linux-x64.tar.gz
3- Extract the file and create a folder where to move it
tar -zxvf jdk-8u65-linux-x64.tar.gz
sudo mkdir -p /opt/java
sudo mv jdk1.8.0_65 /opt/java
4- Make JDK system default
sudo update-alternatives --install "/usr/bin/java" "java"
"/opt/java/jdk1.8.0_65/bin/java" 1
sudo update-alternatives --set java /opt/java/jdk1.8.0_65/bin/java
At this stage, you can start the installation of Netbeans IDE and it will automatically detect your Oracle JDK setting
I tested a short HelloWorld Java example, and I don't have any issue.
Here is the setting JDK view in Netbeans:
If you want to add the JAVA Home dir to your system
Proceed like this
You have to be in root mode and then edit this file: /etc/bash.bashrc
and add:
#JAVA HOME
JAVA_HOME=/opt/java/jdk1.8.0_65
export JAVA_HOME
PATH=$PATH:$JAVA_HOME/bin
export PATH
Reboot your Mint system
Now you'll have javac working in command line...
I have installed openproj_1.4-2.deb on my ubuntu. and I'm getting the following err while openinig the same.
Your Java vendor is "Oracle Corporation". To run OpenProj, you need the Sun Java implementation.
The auto-detected Java Runtime used is..
I have tried to fix by editing $HOME/.openproj/run.conf file by updating JAVA_EXE variable. But it is not working.
How can I run openproj on my Linux?
Please help, Thanks in advance.
(sorry for unable to create a new tag, openproj)
Open $HOME/.openproj/run.conf and Change
JAVA_OPTS="-Xms128m -Xmx768m"
To
JAVA_OPTS="-Djava.vendor=Sun -Xms128m -Xmx768m"
then run it, It will work fine.
I'm able to fix this by adding -Djava.vendor="Sun Microsystems Inc." for java command in run_openproj() of /usr/bin/openproj script.
here is the updated function after my change:
run_openproj() {
if [ "$LOG_LEVEL" ] && [ "x$LOG_LEVEL" = "xDEBUG" ]; then
"$JAVA_EXE" $JAVA_OPTS -Djava.vendor="Sun Microsystems Inc." -jar "$OPENPROJ_HOME/openproj.jar" $ARGS > "$LOG_FILE"
else
"$JAVA_EXE" $JAVA_OPTS -Djava.vendor="Sun Microsystems Inc." -jar "$OPENPROJ_HOME/openproj.jar" $ARGS > /dev/null 2>&1
fi
}
I solved it by installing IBM java version. Note the installation directory, by default it is: /opt/ibm/java-x86_64-80/.
Once IBM java is installed it should be configured to be used by OpenProj.
In order to do that run the following command (maybe the installation path should be updated, this is: /opt/ibm/java-x86_64-80/jre/bin/java):
sudo update-alternatives --install /usr/bin/java java /opt/ibm/java-x86_64-80/jre/bin/java 20000
Now check that the configuration has been saved properly, else set it manually with:
sudo update-alternatives --config java
Now check java version with:
java -version
You should get something similar to this:
java version "1.8.0_351"
Java(TM) SE Runtime Environment (build 8.0.7.20 - pxa6480sr7fp20-20221020_01(SR7 FP20))
IBM J9 VM (build 2.9, JRE 1.8.0 Linux amd64-64-Bit Compressed References 20220929_37824 (JIT enabled, AOT enabled)
OpenJ9 - 02180fe
OMR - 48fc32a
IBM - bf759bf)
JCL - 20220922_01 based on Oracle jdk8u351-b10
Now, OpenProj can be executed properly.
If it fails again you may delete the configuration file:
rm ~/.openproj/run.conf
Im trying to install Java in install but for some reason its not working.
I tried the same way as mentioned in this website-http://www.java.com/en/download/help/linux_install.xml#enable
I see Java installed in my desktop when I try this command,
premvidya#ubuntu:~/Desktop$ ls
jre1.6.0_31 jre-6u31-linux-i586(2).bin jre-6u31-linux-i586.bin
but when I try java - version, I get the following error,
premvidya#ubuntu:~/Desktop$ java -version
The program 'java' can be found in the following packages:
* gij-4.3
* java-gcj-compat-headless
* openjdk-6-jre-headless
* cacao
* gij-4.2
* jamvm
* kaffe
Try: sudo apt-get install
bash: java: command not found
Any help would be appreciated.
Why are you trying to manually install java? There is a repository for this, and it's all managed for you. Uninstall whatever you have put on your system manually and install it via command line.
apt-get cache search java
apt-get cache search jdk
or
start Ubuntu Software Center -> search for java.
Once installed via apt-get, the new java commands will be available immediately in your PATH, so long as you haven't removed anything...
#user1050619
Hi user1050619,
I have come across the solution which will work on any version of Ubuntu definitely keeping other java versions intact.
I have used standalone installation of Java.
For this, please download tar.gz version of Java from
Oracle website.
Suppose, your jdk installation tar file at location /home/don/
don#ubuntu ~ $ tar zxf jdk-7u45-linux-i586.tar.gz
don#ubuntu ~ $ sudo bash
[sudo] password for don:
ubuntu ~ # mv /home/don/jdk1.7.0_45/ /usr/lib/jvm/
ubuntu ~ # cd /usr/lib/jvm/
ubuntu jvm # update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk1.7.0_45/bin/java 3
ubuntu jvm # update-alternatives --config java
Selection Path Priority Status
------------------------------------------------------------
* 0 /usr/lib/jvm/java-7-openjdk-i386/jre/bin/java 1071 auto mode
1 /usr/lib/jvm/java-7-openjdk-i386/jre/bin/java 1071 manual mode
2 /usr/lib/jvm/jdk1.7.0_45/bin/java 3 manual mode
Press enter to keep the current choice[*], or type selection number: 2
update-alternatives: using /usr/lib/jvm/jdk1.7.0_45/bin/java to provide /usr/bin/java (java) in manual mode
ubuntu jvm # java -version
java version "1.7.0_45"
Java(TM) SE Runtime Environment (build 1.7.0_45-b18)
Java HotSpot(TM) Server VM (build 24.45-b08, mixed mode)
and you are done here without any hassles.
Happy programming !!
it should be "apt-cache search java6" or just "apt-cache search java". It'll give you a list of all the package related to java. If you want to install sun's java then you download the java-**.bin file like you did and then run "sudo /bin/sh jre-6u31-linux-i586.bin" That'll run the installer from the sun java you downloaded and begin to install. Answer the question and install the package.