Trợ giúp

Trợ giúp GoDaddy

How to install Java on Ubuntu

Java is used to run such programs as Apache, IntelliJ, Eclipse and many others. Historically, the runtime shipped with Ubuntu, however this changed in 2011. Since then, you've had to manually install the runtime environment to run Java programs or the development environment if you wanted to develop Java programs. For the majority of the population, installing the runtime is sufficient, but in either case, you have to do it for yourself.
DIFFICULTY Basic - 1 | Medium - 2 | Advanced - 3
TIME REQUIRED 15-30+ min
RELATED PRODUCTS Linux-based VPS or dedicated servers

The Oracle implementation of Java is the reference implementation.

Before installing, you need to know if you're running a 32-bit or 64-bit installation of Ubuntu. Run the file command against the init boot startup file to determine its file type and it will report which of the two is installed.

file /sbin/init

This reports results like the following:

/sbin/init: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.24, BuildID[sha1]=0x7aa29ded613e503fb09fb75d94026f3256f01e7a

Next, visit and download the Linux release for your installation, either Linux for the 32-bit release or Linux x64 for the 64-bit version. Follow the instructions on the Oracle site. You'll download a file named something like jre-8u25-linux-i586.tar.gz (32-bit) or jre-8u25-linux-x64.gz (64-bit). The name may differ slightly.

Now, run the rest of the commands as root.

After downloading, create a place to store the unpacked version of what you've just downloaded. You may pick a different place if you wish to install it in a different location.

mkdir /usr/local/java

Next, unpack what you've downloaded into that directory:

cd /usr/local/java
tar -xvzf /tmp/jre-8u25-linux-x64.gz

After unpacking, you'll need to add "Java" to your path so it can be found when you need to run java. Add the following to /etc/profile, make sure to use the directory that was created when you unpacked what you downloaded. There will be a sub-directory specific to the version installed. Use that as your JAVA_HOME. Use your favorite text editor to edit the /etc/profile file.

vi /etc/profile

Add the following to the bottom of file:



export JAVA_HOME

export PATH

The next time you login, you can check to see if you've configured your environment correctly. If you have, the following command will tell you what version is running. It should be the same as what you just installed.

java -version

Output should look like the following

java version "1.8.0_25" Java(TM) SE Runtime Environment (build 1.8.0_25-b17) Java HotSpot(TM) 64-Bit Server VM (build 25.25-b02, mixed mode)

Bài này có hữu ích không?
Cảm ơn về phản hồi của bạn. Để nói chuyện với một đại diện của dịch vụ khách hàng, vui lòng sử dụng số điện thoại hỗ trợ hoặc tùy chọn trò chuyện ở trên.
Rất vui vì chúng tôi đã giúp được bạn! Chúng tôi có thể làm gì thêm cho bạn?
Rất tiếc về điều đó. Vui lòng cho chúng tôi biết điều gì làm cho bạn bối rối và vì sao giải pháp không khắc phục được vấn đề này.