Ubuntu 18.04.1 build Java environment and HelloWorld

One, build a Java environment##

System environment###

1. Download JDK

Official website address: http://www.oracle.com/technetwork/java/javase/downloads/index.html

Select the corresponding version, click jdk, enter the download page, and select the "Linux x64" version of the Linx compressed package with the suffix "xxx.tar.gz".

2. Unzip the JDK compression package###

Find the compressed package in the download, double-click the file, drag the file in the directory to the "/home/stone/java/" directory (equivalent to manual decompression), the "/home/stone/java/" file is my own computer The user can store according to his own directory structure, as shown in the figure below:

Don't ask how my Ubuntu is so similar to a Mac system, I won't tell you, I installed a Mac theme.

3. Configure global system variables###

Open the command line tool and enter the command:

$sudo gedit ~/.bashrc

This command is to modify the global variable file, and paste the following code at the end of the file:

export JAVA_HOME=/home/stone/java/jdk1.8.0_181  
export JRE_HOME=${JAVA_HOME}/jre  
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib  

export PATH=${JAVA_HOME}/bin:$PATH

**Note: ** Among them, "home/stone/java/jdk1.8.0_181" is my own JDK directory, and users need to change to their own storage directory.

The configuration is as follows:

After copying the code, save and leave.

4. Update configuration, test Java installation###

input the command:

sudo source ~/.bashrc

Make the global file take effect. At this point, even if the Java environment is installed successfully, then we enter the command:

java -version

Check the Java version to confirm whether the Java installation is normal, as shown below:

If the above Java version information appears, the installation is successful.

Two, create a Java (Maven) project##

1. Install IDEA Open Tool###

Need to create a Java project, first of all we have to go to the official website and now IDEA development tools, address: https://www.jetbrains.com/idea/download/#section=linux

The download and installation process is relatively simple, we will not do too much introduction here, the installation only needs to enter the IDEA bin directory and execute the command line command:

. /idea.sh

The installation is complete.

2. Crack IDEA

It only takes 3 steps to crack IDEA. Of course, if you have the ability, it is recommended that you buy the genuine one.

3. Create Java Maven Project###

a). New project####

Click File => New => Project..=> Click the "Maven" option on the left, as shown below:

Click Next.

b). Fill in the project information and complete the creation

Then keep clicking "Next" to complete the creation of the project.

c). Create a new java class####

In src/main/java, add the package name "com.hello.java", add the Application.java class, add the main method, output "Hello, Pharaoh", click the debug button to run the project, as shown in the figure above, run successfully, output Print the information, and the entire project is now created.

d).Maven directory structure description####

The main part of the Maven project is shown in the following figure:

The important part is the red part of the chart above, where:

e). Add reference jar package####

As the core function of Maven, it is convenient to reference the jar package, so that we don’t have to find the jar package online, just need to automatically download the jar package after the project root directory pom.xml is configured. The example configuration is as follows:

< dependency><groupId>ch.qos.logback</groupId><artifactId>logback-classic</artifactId><version>1.1.1</version></dependency>

To find the Jar package that the Maven project depends on, visit: http://mvnrepository.com/ Enter the name to easily find and copy the code.

Recommended Posts

Ubuntu 18.04.1 build Java environment and HelloWorld
Ubuntu18.10 configure Java environment
ubuntu16.04 build vim and pyt
ubuntu build python development environment
Embedded Linux development environment to build and configure Ubuntu
Ubuntu environment variables and ADB configuration
Ubuntu16.04 build php5.6 Web server environment
Ubuntu 19.1 installation and configuration Chinese environment
Build a LAMP development environment on Ubuntu 16.04
Build the C++ compilation environment under ubuntu
Configure Java development environment in Ubuntu20.04 LTS
Steps to build LNMP environment on ubuntu 20.04
Build arm virtual operating environment on Ubuntu
Build a python development environment under Ubuntu
Ubuntu build etcd
Ubuntu build Seafile
Install JDK and configure environment variables on Ubuntu 16.04
Installation and use of SSH in Ubuntu environment
ubuntu16.04 deploy GPU environment
Summary: Ubuntu Python2.x and
CentOS6.7 build LNMP environment
Build a basic environment for Java development under Centos7
Ubuntu configuration development environment
Centos7.6 build LNMP environment
Ubuntu20.04 experience and beautification
Ubuntu 18.04 LTS LAMP build
Ubuntu introduction and installation
[python] python2 and python3 under ubuntu
Ubuntu development environment configuration
Python virtual environment: Ubuntu16.04
Ubuntu Touch environment setup
Installation and simple practice of MySQL in ubuntu environment (1)
Lesson 002 ubuntu environment construction and ubuntu graphical interface operation (free)
Ubuntu backup and restore
ubuntu environment deployment project
Install and configure Mono production environment on Ubuntu Server
CentOS 7 build LNMP environment
How to set up Java Home on Ubuntu and Raspbian
How to install memcache and start it in ubuntu environment
How to compile and install PHP and Nginx in Ubuntu environment
Django&amp;MySQL environment deployment under Ubuntu 14.04
Python introduction and environment installation
Build docker environment under Centos6.5
[Linux] Build Samba server (ubuntu16.04)
Ubuntu18.04LTS quickly build CUDA environment
CentOS 7 install JAVA environment (JDK 1.8)
ubuntu 16.04 build pptpd V** server
Ubuntu 16.04 compile and install PHP 7.2
ubuntu sets python2.5 environment variables
ubuntu18.04 compile and install python3.8
ubuntu14.0464 Ros environment install halcon13.01
CentOS6.5 install Java 8 and Tomcat8
Ubuntu16.04 installation and simple configuration
Jmeter (18)_Ubuntu deploy jmeter and ant
Build Ubuntu 12.04 cross compilation server
ubuntu install and configure GitLab
Install Oracle Java8 on Ubuntu
Ubuntu deployment and experience Nexus3
ubuntu1804 build the latest Suricata
CentOS6.5 install Java 8 and Tomcat8
CentOS6.5 install Java 8 and Tomcat8