Archive for the ‘java’ Category

How to create a WAR file

By Automater on July 24th, 2010

Here’s how to compress a ‘pets’ web application into a “Web Archive” file named pets.war so that you can easily transport it to another server.

* Open a command prompt and cd to
\webapps\pets
* Use the java archive command ‘jar’ to bundle up your application
jar -cvf pets.war *
In English, “compress everything in this directory into a file named pets.war”
(c=create, v=verbose, f=file)

Now you can copy pets.war to any the webapps directory on a new Tomcat Server. When you save the file to a new server BE SURE not to save it as a ZIP file, choose “all files”. If Tomcat is running on the new server the war file will be automatically installed as soon as you save it. If not, start up Tomcat on the new server to install the application after you have saved it. Do NOT attempt to unzip the war file or do any installation yourself. Tomcat will do everything for you!

When the server is restarted it will automatically uncompress the files and recreate a web application named ‘pets’. (Do NOT attempt to unzip the war file yourself, let Tomcat take care of all that.)

Posted in

How to install Tomcat 6 on Ubuntu 10.04/Debian

By Automater on July 23rd, 2010

Apache Tomcat is a free and open source software implementation for JavaServlets, providing support for Java Server Pages (JSP). Many popular web-based applications use servlets. You may choose to run Tomcat with either Sun’s Java implementation or the OpenJDK implementation of Java.

Because Tomcat version 6 was included in Ubuntu 10.04, installing a working Tomcat server is reasonably straightforward. However, before we can start installing Tomcat itself, we must first install Java.

First Install Sun Java in ubuntu 10.04

Install tomcat 6 in ubuntu 9.04

1
sudo apt-get install tomcat6 tomcat6-admin tomcat6-common tomcat6-user tomcat6-docs tomcat6-examples

Start tomcat server

1
sudo /etc/init.d/tomcat6 start

Stop tomcat server

1
sudo /etc/init.d/tomcat6 stop

Restart tomcat server

1
sudo /etc/init.d/tomcat6 restart

Get tomcat server status

1
sudo /etc/init.d/tomcat6 status

After installation type http://localhost:8080 or http://serverip:8080/examples/servlets/ in your browser.Now you should see tomcat welcome page

* To enable admin web based features add the following lines to your /etc/tomcat6/tomcat-user.xml

1
2
3
4
5
<role rolename="manager"/>
<role rolename="admin"/>
<user name="admin" password="secret_password" roles="manager,admin"/>

* you should be able to see your manage page here http://your_ip_goes_here:8080/manager/html

* log in with the name and password you just set in /etc/tomcat6/tomcat-users.xml

* ls /var/lib/tomcat6 directory.

* you should see these directories conf, logs, webapps, work

* webapps is where your servlets will go ( or at least a xml file that points to them )

* as a test download this war file http://simple.souther.us/SimpleServlet.war

* then use the tomcat management page and select war file to deploy ( in the deploy section) to upload this file to your server

* optionally just wget http://simple.souther.us/SimpleServlet.war directly to the webapps folder

* tomcat should recognize the war file and expand it with everything you need

* browse to http://serverip:8080/SimpleServlet/

Change tomcat server to run on port 80

If you want to Change tomcat server to run on port 80 follow this procedure

You need to edit the /etc/tomcat6/server.xml file

1
nano /etc/tomcat6/server.xml

Now replace the part that says Connector port=”8080? with Connector port=”80?

Save and exit the file

Restart tomcat server with the following command

1
sudo /etc/init.d/tomcat6 restart
Posted in

Install sun java 6 on ubuntu 10.04

By Automater on May 19th, 2010
1
2
3
4
5
6
7
8
9
<strong>$ sudo   add-apt-repository  "deb <a title="http://archive.canonical.com/" href="http://archive.canonical.com/">http://archive.canonical.com/</a> lucid partner"
$ sudo apt-get update
$ sudo  apt-get install sun-java6-jdk
or {Depending upon what  you need)
$ sudo apt-get install  sun-java6-jre</strong>
Posted in