DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Newsletter
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • I Built a Java Version Manager by Fixing Other Tools' Open Bugs
  • A Spring Boot App With Half the Startup Time
  • Alternative Structured Concurrency
  • Optimizing Java Applications for Arm64 in the Cloud

Trending

  • How to Migrate From LangChainGo to Genkit Go
  • Should Developers Switch From SQLite to DuckDB?
  • SSRF Prevention in C#: Securing File Imports From User-Supplied URLs
  • Delta Lake UniForm to Snowflake: Cross-Platform Table Access Without a Second Copy

Draft This article hasn't been published, so readers can't see it.

In moderation This article is waiting for review, so readers can't see it yet.

Deleted This article has been deleted, so readers can't see it.

  1. DZone
  2. Coding
  3. Java
  4. How to Set Up JDK and Tomcat on Ubuntu

How to Set Up JDK and Tomcat on Ubuntu

This quick tutorial will guide you in setting up the latest JDK and Tomcat on Ubuntu, complete with the necessary code and commands.

By 
Mafijur Rahman
·
Dec. 29, 17 · Tutorial
Post on X (opens in a new tab) Share on LinkedIn (opens in a new tab)
9.2K Views

Join the DZone community Save articles, join the discussion, and download Refcards and Trend Reports with a free account.

Join for free Already a member? Log in

Step 1: Download the latest JDK and Tomcat (in this article, I am using JDK 9 and Tomcat 9).

Step 2: Change the permissions and ownership of the "opt" directory.

user@group:~$ chown username:groupname /opt -R
user@group:~$ chmod 755 /opt -R

Step 3: Now unzip the JDK and Tomcat zip files and copy them to the "opt" directory.

 user@group:~$ cp Downloads/jdk-9.0.1 -Rf /opt/
 user@group:~$ cp Downloads/apache-tomcat-9.0.1 -Rf /opt/tomcat-9

Step 4: Now we need to add some lines to the bottom of the "bashrc" file. To open the "bashrc" file:

 user@group:~$ vim .bashrc

Then press "i" to enable insert mode.

Now add these lines to end of "bashrc":

export CATALINA_HOME=/path/of/tomcat
export CATALINA_OPTS="-Xms256m -Xmx512m -XX:MaxPermSize=128m" 
export MAVEN_OPTS="-Xms256m -Xmx512m" 
export JAVA_HOME=/path/of/jdk 
export JDK_HOME=/path/of/jdk
export IDEA_JDK=/path/of/jdk
export M2_HOME=/path/of/maven 
export PATH=${JAVA_HOME}/bin:${M2_HOME}/bin:${PATH}

After adding the lines, press "Esc" to enable read-only mode. After that, press "Shift + ;" and type "wq" to save the "bashrc" file.

Then, run the following command to set the source of the "bashrc" file:

 user@group:~$ source .bashrc

To check the Java version:

 user@group:~$ java ­-version 

It will show results like so:

Java version "9.0.1" 
Java(TM) SE Runtime Environment (build 9.0.1+11) 
Java HotSpot(TM) 64­Bit Server VM (build 9.0.1+11, mixed mode)

Now start the Tomcat server by running the following command:

 user@group:~$ /path/to/tomcat/bin/startup.sh 

Note: “user@group:~$” is your system default. Don't need to copy it.

Java (programming language) Java Development Kit Apache Tomcat ubuntu

Opinions expressed by DZone contributors are their own.

Related

  • I Built a Java Version Manager by Fixing Other Tools' Open Bugs
  • A Spring Boot App With Half the Startup Time
  • Alternative Structured Concurrency
  • Optimizing Java Applications for Arm64 in the Cloud

Partner Resources

×

Comments

Loading comments

The comments didn't load

Please try again in a moment.

Likes

Loading

The next likes didn't load. Please try again.

The likes didn't load

Please try again in a moment.

See who liked this

Log in or join DZone for free to see who liked this article.

Log in Join for free
  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook