search
HomeJavajavaTutorialHow to set up a Java Web project running environment on a Linux system?

1. Install jdk

1. Uninstall the old version or the jdk that comes with the system

(1) List all installed jdk

 rpm -qa | grep jdk

(2) Uninstall unnecessary jdk

 yum -y remove installation package name

2. Download and decompress jdk

(1) Download the installation package

Enter the /usr/local directory and create a new java directory

mkdir java

​, use the wget command in the java directory to download the installation package, such as

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/8u141-b15/336fa29ff2bb4ef291e347e091f7f4a7/jdk-8u141-linux-x64.tar.gz

​, or use the shell tool to upload it locally to Linux.

(2) Decompress the installation package

After downloading, use the command to decompress,

tar -zxvf compressed package name

3 .Configure environment variables

Enter the /etc/ folder and use the vim profile command editor to edit the profile file (global environment variable configuration). If there is no profile file, go to /root to configure the .bash_profile file (environment variable configuration under the current user) and add the following configuration at the end of the file: (If you are worried about modification errors, you can use the ps command to back up the file)

export java_home=jdk安装包的根目录
  export path=$java_home/bin:$path
  export classpath=.:$java_home/lib/dt.jar:$java_home/lib/tools.jar:$java_home/jre/lib/rt.jar  

Finally, don’t forget to execute the command

 source /etc/profile

to make the configuration file take effect.

Enter java -version to check whether the jdk configuration is successful. If the version information appears, the jdk installation and configuration is completed.

2. Install tomcat

2. Download and decompress tomcat

(1) Download the installation package

Enter /usr Create a new mywork directory in the /local directory

  mkdir mywork

 , and use the wget command in the mywork directory to download the installation package, such as

 wget "" 

Or use shell tools to download locally and upload to linux.

(2) Decompress the installation package

After downloading, use the command to decompress,

 tar -zxvf compressed package name

3 .Start tomcat

Enter the main directory of tomcat, start tomcat, use the command

 bin/startup.sh

Check whether tomcat is started Success (whether the process exists), use the command

 ps -ef | grep tomcat

4. Check whether tomcat is installed successfully

(1) Check Firewall status

 systemctl status firewalld

Use the command if the above command is invalid

 service iptables status

(2) Turn off the linux firewall

 systemctl stop firewalld

Use the command if the above command is invalid

 service iptables stop

(3) Check the ip address information of linux

  ifconfig

(4) Visit tomcat

Enter the address in the browser, address: 8080

3. Install mysql

1. Uninstall the system’s own database mariadb

yum list installed | grep mariadb (查看系统是否安装了mariadb)

  yum -y remove 应用名称  (卸载mariadb)

2. Download and unzip mysql

(1) Download the installation package

Enter the /usr/local directory and use the wget command to download the installation package, such as

wget "http://dev.mysql.com/get/ downloads/mysql-5.7/mysql-5.7.17-linux-glibc2.5-x86_64.tar.gz"

Or use the shell tool to upload it to Linux locally.

(2) Decompress the installation package

After downloading, use the command to decompress,

tar -zxvf compressed package name

Decompress After completion, change the file name,

 mv decompress the file name mysql

3. Create the data warehouse directory

 mkdir /mysql/data ( This directory stores database data)

4. Create mysql user and user group

  groupadd mysql (创建用户组)
  useradd -r -s /sbin/nologin -g mysql mysql -d /usr/local/mysql  (将mysql用户添加至组中并为用户指定mysql目录)

5. Specify the owner of the directory

进入到mysql根目录
  cd /usr/local/mysql
  改变目录所有者,
  chown -r mysql .  (不要忘记后面的.)
  chgrp -r mysql .
  chown -r mysql /mysql/data

6. Initialize mysql configuration parameters

在mysql根目录下执行,
  bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/mysql/data
  注意:命令执行后在末尾处会生成初始密码,将其复制到记事本中用于后面首次登录。
  设置数据加密,
  bin/mysql_ssl_rsa_setup --datadir=/mysql/data

7. Modify the system configuration file

将mysql配置文件添加到系统配置文件中,进入目录
  cd /usr/local/mysql/support-files
  复制,
  cp my-default.cnf /etc/my.cnf
  cp mysql.server /etc/init.d/mysql
  编辑mysql配置文件,指定基础目录和数据目录,
  vim /etc/init.d/mysql
  修改如下属性:
  basedir=/usr/local/mysql
  datadir=/mysql/data

8. Modify the password

启动mysql,
  /etc/init.d/mysql start  --5.0版本是 mysqld start
  登录,
  mysql -h localhost -u root -p
  输入第(6)步拿到的密码。如果出现:-bash :mysql :commond not found 就执行:ln -s /usr/local/mysql/bin/mysql /usr/bin  --创建命令软连接
  修改密码,
  set password=password('你要设置的密码')

9. Modify the operation of the remote host for the root user Permissions

Give all hosts all permissions

grant all privileges on *.* to 'root'@'%' identified by 'root'; 

Make permissions effective

flush privileges; 

View user table permissions

 use mysql;
  select * from user;

10. Add system environment variables

vim /etc/profile 

Add at the end:


export path=/usr/local/mysql/bin:$path 

Make the configuration file effective

source /etc/profile<br>

11. Remote connection test

You can use the mysql client tool to connect remotely. If the connection fails, you can close the firewall and try again.

Supplement:

Check the running status of mysql,
service mysql status --5.0 version is service mysqld status
Stop mysql,
service mysql stop --5.0 version is service mysqld stop
Start mysql
service mysql start --The 5.0 version is service mysqld start
Restart mysql
service mysql restart --The 5.0 version is service mysqld restart

mysql can be passed Modify /etc/my.cnf for detailed configuration.

The above is the detailed content of How to set up a Java Web project running environment on a Linux system?. For more information, please follow other related articles on the PHP Chinese website!

Statement
This article is reproduced at:亿速云. If there is any infringement, please contact admin@php.cn delete
Explain how the JVM acts as an intermediary between the Java code and the underlying operating system.Explain how the JVM acts as an intermediary between the Java code and the underlying operating system.Apr 29, 2025 am 12:23 AM

JVM works by converting Java code into machine code and managing resources. 1) Class loading: Load the .class file into memory. 2) Runtime data area: manage memory area. 3) Execution engine: interpret or compile execution bytecode. 4) Local method interface: interact with the operating system through JNI.

Explain the role of the Java Virtual Machine (JVM) in Java's platform independence.Explain the role of the Java Virtual Machine (JVM) in Java's platform independence.Apr 29, 2025 am 12:21 AM

JVM enables Java to run across platforms. 1) JVM loads, validates and executes bytecode. 2) JVM's work includes class loading, bytecode verification, interpretation execution and memory management. 3) JVM supports advanced features such as dynamic class loading and reflection.

What steps would you take to ensure a Java application runs correctly on different operating systems?What steps would you take to ensure a Java application runs correctly on different operating systems?Apr 29, 2025 am 12:11 AM

Java applications can run on different operating systems through the following steps: 1) Use File or Paths class to process file paths; 2) Set and obtain environment variables through System.getenv(); 3) Use Maven or Gradle to manage dependencies and test. Java's cross-platform capabilities rely on the JVM's abstraction layer, but still require manual handling of certain operating system-specific features.

Are there any areas where Java requires platform-specific configuration or tuning?Are there any areas where Java requires platform-specific configuration or tuning?Apr 29, 2025 am 12:11 AM

Java requires specific configuration and tuning on different platforms. 1) Adjust JVM parameters, such as -Xms and -Xmx to set the heap size. 2) Choose the appropriate garbage collection strategy, such as ParallelGC or G1GC. 3) Configure the Native library to adapt to different platforms. These measures can enable Java applications to perform best in various environments.

What are some tools or libraries that can help you address platform-specific challenges in Java development?What are some tools or libraries that can help you address platform-specific challenges in Java development?Apr 29, 2025 am 12:01 AM

OSGi,ApacheCommonsLang,JNA,andJVMoptionsareeffectiveforhandlingplatform-specificchallengesinJava.1)OSGimanagesdependenciesandisolatescomponents.2)ApacheCommonsLangprovidesutilityfunctions.3)JNAallowscallingnativecode.4)JVMoptionstweakapplicationbehav

How does the JVM manage garbage collection across different platforms?How does the JVM manage garbage collection across different platforms?Apr 28, 2025 am 12:23 AM

JVMmanagesgarbagecollectionacrossplatformseffectivelybyusingagenerationalapproachandadaptingtoOSandhardwaredifferences.ItemploysvariouscollectorslikeSerial,Parallel,CMS,andG1,eachsuitedfordifferentscenarios.Performancecanbetunedwithflagslike-XX:NewRa

Why can Java code run on different operating systems without modification?Why can Java code run on different operating systems without modification?Apr 28, 2025 am 12:14 AM

Java code can run on different operating systems without modification, because Java's "write once, run everywhere" philosophy is implemented by Java virtual machine (JVM). As the intermediary between the compiled Java bytecode and the operating system, the JVM translates the bytecode into specific machine instructions to ensure that the program can run independently on any platform with JVM installed.

Describe the process of compiling and executing a Java program, highlighting platform independence.Describe the process of compiling and executing a Java program, highlighting platform independence.Apr 28, 2025 am 12:08 AM

The compilation and execution of Java programs achieve platform independence through bytecode and JVM. 1) Write Java source code and compile it into bytecode. 2) Use JVM to execute bytecode on any platform to ensure the code runs across platforms.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version