java install tomcat as service - java

I'm planning to develop an application installer which, as a part of installation, installs Apache Tomcat on Linux. Does anyone know how can I programmatically install Tomcat as service on Linux.
Best

If you have Tomcat installed already, you probably need to put a start up script for Tomcat in /etc/init.d
This article has a decent start up script.
http://www.howtogeek.com/howto/linux/installing-tomcat-6-on-ubuntu/

Tomcat7 (Stable release 2011 January) For Debian-base: Tested in Ubuntu 14.04.
Install Tomcat7:
sudo apt-get install tomcat7 tomcat7-docs tomcat7-admin
sudo apt-get install libtomcat7-java tomcat7-common tomcat7-examples
Start the tomcat server:
sudo service tomcat7 restart
Check whether the the tomcat is running or not by access the URL http:/127.0.0.1:8080 in browser or in terminal:
w3m http://127.0.0.1:8080
More...

If you are on a debian-base distribution, just type
sudo apt-get install tomcat6 tomcat6-admin tomcat6-examples
and you'll have a tomcat fully functional (example for Ubuntu 10.04)

Related

installing tomcat 9 on WSL

After installing tomcat 9 on WSL, it isn't recognized by system.
Since systemctl command doesn't work on WSL, I used below command:
sudo service tomcat9 start
returning
tomcat9: unrecognized service
I followed 2 ways to install, but the same problem occurred.
References are:
https://www.digitalocean.com/community/tutorials/install-tomcat-9-ubuntu-1804
https://linuxconfig.org/ubuntu-20-04-tomcat-installation
Is there any clue for this problem?
Here is my environment:
windows 10 version 2004
ubuntu 20.04 (WSL)
openjdk version: "1.8.0_265"
update:
I did same process on gcp vm instance on which ubuntu 20.04 is installed to investigate the problem, and found the process has no problem on ubuntu 20.04, not on WSL.
So I assume that this problem is derived from WSL.
Logging all my process expecting someone to find a solution to install tomcat 9 on WSL-ubuntu.
java install
sudo apt update
sudo apt install openjdk-8-jdk
set JAVA_HOME in /etc/environment
JAVA_HOME="/usr/lib/jvm/java-8-openjdk-amd64/jre/bin"
source /etc/environment
tomcat 9 install
sudo apt install tomcat9 tomcat9-admin
check whether port 8080 is open (positive)
ss -ltn
check whether service command works (positive)
sudo service tomcat9 stop
sudo service tomcat9 start
It seems the tomcat9 package is broken.
To use tomcat9 on your WSL you may either :
download tomcat9 and install it by yourself
try to repair the broken install
Here is what I did to repair the install on my computer :
Download a zip version of tomcat 9 from https://tomcat.apache.org/download-90.cgi
in windows explorer open the folder \wsl$\Ubuntu\usr\share\tomcat9
In order to repair tomcat I copied all the missing folders from the zip to the wsl installation : conf, webapps and work
I also had to create the folder for the logs /usr/share/tomcat9/logs (you can either create it from linux shell or from windows explorer in \wsl$\Ubuntu)
Then I could start tomcat with sudo /usr/share/tomcat9/bin/startup.sh and get the logs in /usr/share/tomcat9/logs/catalina.out
I solved the problem by following steps:
enable systemd, see WSL 2 - Enabling systemd
restart WSL Ubuntu, with cmd wsl --shutdown and wsl -d Ubuntu genie -s
reinstall tomcat9, with shell apt-get remove tomcat9 and apt-get install tomcat9
then type service tomcat9 status, see how things work in your machine.

How to install Hadoop on MacOs?

I have MacOs when I install Hadoop I used this Command sudo apt install hadoop-yarn-resourcemanager
I got below error
Unable to locate an executable at "/Library/Java/JavaVirtualMachines/jdk-11.0.1.jdk/Contents/Home/bin/apt"
apt is the Debian / Ubuntu Linux package management system. What makes you think that MacOs supports Debian packages?!
Instead you could install and use the brew package manager.
See https://isaacchanghau.github.io/post/install_hadoop_mac/ for example.

Installing Apache tomcat using bash script using Java

Hi I'm planning to devolep a APP that will install install programs using bash commands Ie to install tomcat
apt-get install tomcat7
Is it possible to achieve it programmatically using Java
Use Runtime.exec() method to run external command. For more refer: http://www.tutorialspoint.com/java/lang/runtime_exec.htm

A way to start tomcat with other java

I am exporting variables in the setenv.sh like this:
JAVA_HOME=/home/arthur/java8
JRE_HOME=/home/arthur/java8/jre
CATALINA_HOME=/home/arthur/tomcat8
PATH=$CATALINA_HOME/bin:$PATH
PATH=$JAVA_HOME/bin:$PATH
But tomcat started from tomcat8 folder starts with java6 variable.
Why?
Thank you!
Try configuring tomcat configuration file using command
sudo vim /etc/default/tomcat7
...
The home directory of the Java development kit (JDK). You need at
least JDK version 1.5. If JAVA_HOME is not set, some common
directories for OpenJDK, the Sun JDK, and various J2SE 1.5 versions
are tried.
JAVA_HOME=/usr/lib/jvm/openjdk-6-jdk
JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64
...
Then restart the server
sudo service tomcat7 restart
You can use below command to check Tomcat is using which JDK
sudo service tomcat7 status

Installing Jenkins on Ubuntu

I am trying to install Jenkins on ubuntu 11.04
I have installed Oracle Java
$:~$ java -version
java version "1.8.0_05"
Java(TM) SE Runtime Environment (build 1.8.0_05-b13)
Java HotSpot(TM) Server VM (build 25.5-b02, mixed mode)
$:~$ javac -version
javac 1.8.0_05
$:~$
$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/lib/jvm/jdk1.8.0_05/bin:/usr/lib/hadoop/hadoop-1.2.0/bin/:/usr/lib/pig/pig-0.12.0/bin:/usr/lib/hive/hive-0.11.0/bin:/usr/lib/hbase/hbase-0.94.8/bin
$:~$ echo $JAVA_HOME
/usr/lib/jvm/jdk1.8.0_05
When I try to install, I have some dependency issues..
$ sudo apt-get install jenkins
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
jenkins : Depends: daemon but it is not installable
Depends: default-jre-headless but it is not installable or
java-runtime-headless but it is not installable
E: Broken packages
to work install Jenkins they request Java versions greater than 1.8.0_1.
I got hte same error and I updated java to below version
java -version
java version "1.8.0_121"
Now jenkins installing without errors
Below link worked for 14.04 (hope it works for 11.04 too)
Install Java version in ubuntu
Try this:
sudo apt-get update
sudo apt-get remove default-jre default-jdk
sudo apt-get update
sudo apt-get install default-jre default-jdk
More about java on Ubuntu:
https://www.digitalocean.com/community/tutorials/how-to-install-java-on-ubuntu-with-apt-get
Steps to install jenkins and view in browser with IP:-
sudo apt update
sudo apt search jdk --to search jdk
sudo install openjdk-8-jre
sudo install openjdk-8-jre-headless
wget -q -O - https://pkg.jenkins.io/debian/jenkins.io.key | sudo apt-key add -
add below line in the file /etc/apt/sources.list:
sudo nano /etc/apt/sources.list
OR
sudo vi /etc/apt/sources.list
Add this below link at the end of editing document.
deb https://pkg.jenkins.io/debian binary/
Update your local package index
sudo apt-get update
Install jenkins now
sudo apt install jenkins
start jenkins service
sudo systemctl start jenkins
Enable the jenkins service
sudo systemctl enable jenkins
Now jenkins installed in your system. If are following these steps
you are good to go. heat localhost:8080 in the browser. because jenkins works on
8080 by default. you can change it's port to others.
Now if are using google cloud then there is one more step.
Firewall rule details (Add firewall rule to enable ip and tcp 8080 port)
That's that now if you open in browser http://<your-ip>:8080 jenkins will open and ask you
to view the password which give location on the ui.
For more detail please visit
https://www.jenkins.io/
Your installation of Java is likely the Oracle zip / tgz drop. By using it, the package manager (dpkg / apt in this case) is unaware it is installed.
Install the packaged java for the package manager to "know" that the right java is isntalled, or install the zip / tgz drop of jenkins.
In short, if you want managed Jenkins, use the managed Java, and if you don't want it to be managed (sometimes that's a good option if you don't want it to be upgraded), don't use the managed Jenkins or Java. (Keep in mind that unmanaged means you get none of the bug fixes until you manually update, but it also means you get no surprises until you manually update).
Seems like you should run
sudo apt-get update
sudo apt-get upgrade
And try again.
Anyway, Jenkins users quite frecuently complain about the installer not working.
Your life will be easier if you do it manually. It is quite easy and you have complete instructions all around the web: http://clavadetscher.dyndns.org/wiki/en/Install_and_upgrade_Jenkins_CI_Server_on_Ubuntu_12.04_and_Tomcat6
note: tomcat7 (if you are tempted) has given me some headaches with Jenkins. I always end up installing tomcat6.
Ended up solving this by running the following command:
sudo add-apt-repository universe
Pre-made script for install Jenkins and it will also print the access code to the console for the first login as well.
You should be able to copy and paste
cd ~/
git clone https://github.com/120GBSSD/jenkins-install-xenial.git
chmod +x ~/jenkins-install-xenial/Ubuntu:16.04-Jenkins.sh
./Ubuntu:16.04-Jenkins.sh

Categories