Install JDK under Ubuntu14.04.2 and configure the Jetty Server

Source: Internet
Author: User
Then we move the directory/

Let's talk about

Upload to Ubuntu Server

Run the tar-xvf jdk-7u80-linux-x64.gz and unzip it to the current directory

Tar-xvf jdk-7u80-linux-x64.gz

Then we move the directory to/usr/lib/jvm.

Mv jdk1.7.0 _ 80/usr/lib/jvm/jdk1.7.0 _ 80

Run the chmod command to add executable permissions to the jdk directory.

Sudo chmod u + x/usr/lib/jvm/jdk1.7.0 _ 80/bin

Set the JDK environment variables. For more information, see:

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

Setting JDK environment variables in Linux (three methods for configuring environment variables)

①. Modify the/etc/profile file

This method is recommended if your computer is used only for development, because all users' shells have the right to use these environment variables, which may bring security issues to the system.
· Open in a text editor/Etc/profile
· Add at the end of the profile file:
JAVA_HOME =/usr/share/jdk1.5.0 _ 05
PATH = $ JAVA_HOME/bin: $ PATH
CLASSPATH =.: $ JAVA_HOME/lib/dt. jar: $ JAVA_HOME/lib/tools. jar
Export JAVA_HOME
Export PATH
Export CLASSPATH

· Log on again
· Description
A. Change/usr/share/jdk1.5.0 _ 05jdk to your jdk installation directory.
B. Use the colon ":" To separate paths in linux
C. $ PATH/$ CLASSPATH/$ JAVA_HOME is used to reference the original environment variable value. When setting the environment variable, pay special attention not to overwrite the original value, this is a common error.
D. The current directory "." In CLASSPATH cannot be lost. It is also a common error to discard the current directory.
E. export exports the three variables as global variables.
F. Case sensitivity is required.

②. Modify. BashrcFile
    
This method is more secure. It can control the permissions to use these environment variables to the user level. If you need to grant a user permission to use these environment variables, you only need to modify. you can use the bashrc file.
· Open in a text editorThe. bashrc file in the user directory
· In. BashrcAdd at the end of the file:
Set JAVA_HOME =/usr/share/jdk1.5.0 _ 05
Export JAVA_HOME
Set PATH = $ JAVA_HOME/bin: $ PATH
Export PATH
Set CLASSPATH =.: $ JAVA_HOME/lib/dt. jar: $ JAVA_HOME/lib/tools. jar
Export CLASSPATH
· Log on again

③ Directly set variables in shell

I am not in favor of using this method. If you change the shell, your settings will be invalid. Therefore, this method is only for temporary use and will be re-set later, which is troublesome.
Run the following command on the shell terminal:
Export JAVA_HOME =/usr/share/jdk1.5.0 _ 05
Export PATH = $ JAVA_HOME/bin: $ PATH
Export CLASSPATH =.: $ JAVA_HOME/lib/dt. jar: $ JAVA_HOME/lib/tools. jar

Open the terminal and enter the command"Java-version". If JDK version information is displayed, the environment variable is successfully configured.

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

Sudo vi/etc/profile

Add a profile before it ends

Save and exit

Because ubuntu may have a default JDK, such as openJdk, set the default JDK.

Update-alternatives -- install/usr/bin/java/usr/lib/jvm/jdk1.7.0 _ 80/bin/java 300
Update-alternatives -- install/usr/bin/javac/usr/lib/jvm/jdk1.7.0 _ 80/bin/javac 300

Add the JDK we installed to the java menu through the above step.

You can run the following command to query all JDK menus:

Update-alternatives -- list java

Next, run the following command to select the JDK installed by default.

Update-alternatives -- config java

Select the serial number if there are multiple

Next, check whether the java version is correct.

Java-version

If correct, the JDK is successfully installed.

Next, install and configure jetty.

First, download jetty from the eclipse website. Because my local development environment uses jetty8, the server also downloads jetty8.

Jetty-distribution-8.1.17.v20150415.tar.gz

After uploading to the unbuntu server, run the following command to decompress

Tar-xvf jetty-distribution-8.1.17.v20150415.tar.gz

Then move the jetty directory to/opt/jetty.

Music jetty-distribution-8.1.17.v20150415/opt/jetty

Next, create a jetty user, use it for the configuration file, and set it to the host in the/opt/jetty directory.

Sudo useradd jetty-U-s/bin/false
Sudo chown-R jetty: jetty/opt/jetty

Next, copy the jetty script to the startup directory and run it as a service.

Cp/opt/jetty/bin/jetty. sh/etc/init. d/jetty

Next, we will create the jetty configuration file.

Sudo vi/etc/default/jetty

Add the following content

Save and exit

Then you can run the command to start the Jetty service.

Sudo service jetty start

If it is normal, the following page is displayed:

I did not install jdk because I had installed JDk on ubuntu, but I still cannot find JDK at startup because the default JDK version is incorrect, you need to perform the default JDK change operation above, so that no error will be reported during startup.

So far, Server installation is complete

Next, configure your website directory to the server.

All Jetty configuration files are stored in the $ {JETTY_HOME}/etc directory.

From the $ {JETTY_HOME}/etc/jetty-webapps.xml file, we can see that Jetty places all web apps under the $ {JETTY_HOME}/webapps directory by default.

The Jetty package contains a test by default. for war applications, you can find this file in the $ {JETTY_HOME}/webapps directory. By default, test is deployed when the Jetty service is started. war application. For test. war file, Jetty also defines the context file, put it in $ {JETTY_HOME}/contexts/test. in xml, contextPath is defined as "/", which is why the test application is accessed by default when http: // localhost: 8080/is accessed.

Deploy new web Applications

To deploy a war package, you only need to put the war file under the $ {JETTY_HOME}/webapps directory, and then you can directly access it through a browser.

For web application directory deployment, you can copy the web application directory to $ {JETTY_HOME}/webapps/ Directory, and then in $ {JETTY_HOME}/contexts/ . Xml file with the following content




/Myapp
/Webapps/myapp

Restart the Jetty service and access http: // localhost: 8080/myapp to view the newly deployed web application.

Use Jetty as an Embedded Server http://www.linuxidc.com/Linux/2013-07/86983.htm

Jetty source code analysis http://www.linuxidc.com/Linux/2013-10/90986.htm

Jetty install learn and present http://www.linuxidc.com/Linux/2014-05/101993.htm

Jetty installation http://www.linuxidc.com/Linux/2013-10/90991.htm in Eclipse

Install Jetty deployment using http://www.linuxidc.com/Linux/2014-10/108342.htm in Linux (RedHat 5.8)

Jetty details: Click here
Jetty's: Click here

For more information about Ubuntu, see Ubuntu special page http://www.linuxidc.com/topicnews.aspx? Tid = 2

This article permanently updates the link address: Http://www.linuxidc.com/Linux/2015-08/122233.htm

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.