java not found_java command not found

INSTALLATION PROCEDURE ON RASPBERRY PI

The remaining steps should be performed directly on the console of the Raspberry Pi or using a SSH terminal connection with shell access.  In the last step, we transfered the Oracle JDK file to the "pi" user's home directory.  We should be logged in as the "pi" user and already in the user's home directory.

Lets create a new directory where we will install the JDK files to.

sudo mkdir -p -v /opt/java

Next, lets unpack the Oracle JDK .gz file using this command

tar xvzf ~/jdk-7u10-linux-arm-sfp.gz

d6cd47779165e903b9d8bfb3a9feeb3d.pngThe unpacking process will take a few seconds to complete.  It unpacks all the contents of the Oracle JDK tz file to a new directory named "jdk1.7.0_10" located in the user's home directory.

With the unpack complete its now time to move the new unpacked directory to the Java install location that we created earlier under "opt/java".

sudo mv -v ~/jdk1.7.0_10 /opt/java

We can also delete the original .tz file as it is no longer needed

rm ~/jdk-7u10-linux-arm-sfp.gz

To complete the JDK installation we need to let the system know there is a new JVM installed and where it is located.  Use the following command to perform this task.

sudo update-alternatives --install "/usr/bin/java" "java" "/opt/java/jdk1.7.0_10/bin/java" 1

And finally we also need to tell the system that we want this JDK to be the default Java runtime for the system. The following command will perform this action.

sudo update-alternatives --set java /opt/java/jdk1.7.0_10/bin/java

fe01399a7ac5c2ff60c9098bedc98280.png

Now java is installed.  To test and verify we can execute the java command using the version argument.

java -version

You should get the following response:

48f637239b19339d2f5ffdcfc39a7de6.png

That's it the Oracle JDK is installed and ready for use.

ADD JAVA_HOME ENVIRONMENT VARIABLE

Some Java programs require a JAVA_HOME environment variable to be configured on the system.  Add the following line to you "/etc/environment" using your favorite text editor.

JAVA_HOME="/opt/java/jdk1.7.0_10"

Also, edit your "~/.bashrc" file using this command

nano ~/.bashrc

and add the following two lines to the bottom of the file and save.

export JAVA_HOME="/opt/java/jdk1.7.0_10"

export PATH=$PATH:$JAVA_HOME/bin

Reboot or re-login to apply the export to your environment.

------------------------------------------------------------------------

att:

sudo update-alternatives --install "/usr/bin/java" "java" "/opt/javak1.7.0_10/bin/java" 1

--install

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值