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
Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
View Events Video Library
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Migrate, Modernize and Build Java Web Apps on Azure: This live workshop will cover methods to enhance Java application development workflow.

Modern Digital Website Security: Prepare to face any form of malicious web activity and enable your sites to optimally serve your customers.

Kubernetes in the Enterprise: The latest expert insights on scaling, serverless, Kubernetes-powered AI, cluster security, FinOps, and more.

A Guide to Continuous Integration and Deployment: Learn the fundamentals and understand the use of CI/CD in your apps.

Related

  • Installing Open JDK 8 on Ubuntu
  • JAX-WS Five-Minute Tutorial
  • A Maven Story
  • Ways To Reduce JVM Docker Image Size

Trending

  • The Advantage of Using Cache to Decouple the Frontend Code
  • Reading an HTML File, Parsing It and Converting It to a PDF File With the Pdfbox Library
  • A Roadmap to True Observability
  • Understanding Zero Trust Security Building a Safer Digital World
  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.

Mafijur Rahman user avatar by
Mafijur Rahman
·
Dec. 29, 17 · Tutorial
Like (6)
Save
Tweet
Share
8.4K 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

  • Installing Open JDK 8 on Ubuntu
  • JAX-WS Five-Minute Tutorial
  • A Maven Story
  • Ways To Reduce JVM Docker Image Size

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

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 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends: