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
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • Alternative Structured Concurrency
  • Optimizing Java Applications for Arm64 in the Cloud
  • 1-Line IO in Java
  • Jakarta WebSocket Essentials: A Guide to Full-Duplex Communication in Java

Trending

  • Ingesting Fixed-Width Mainframe Files Into Delta Lake: The Details Nobody Writes Down
  • Lambda-Driven API Design: Building Composable Node.js Endpoints With Functional Primitives
  • From AI Chaos to Control: Building Enterprise-Grade LLM Gateways With MuleSoft Anypoint
  • Building a DevOps-Ready Internal Developer Platform: A Hands-On Guide to Golden Paths, Self-Service, and Automated Delivery Pipelines
  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 user avatar
Mafijur Rahman
·
Dec. 29, 17 · Tutorial
Likes (6)
Comment
Save
Tweet
Share
9.1K Views

Join the DZone community and get the full member experience.

Join For Free

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

  • Alternative Structured Concurrency
  • Optimizing Java Applications for Arm64 in the Cloud
  • 1-Line IO in Java
  • Jakarta WebSocket Essentials: A Guide to Full-Duplex Communication in Java

Partner Resources

×

Comments

The likes didn't load as expected. Please refresh the page and try again.

  • 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