|
|
JAVA, JSP, SERVLETS, TOMCAT, SERVLETS MANAGER,
Private JVM (Java Virtual Machine),
Private Tomcat Server
Alden Hosting offers private JVM (Java Virtual Machine), Java Server Pages (JSP), Servlets, and Servlets Manager with our Web Hosting Plans
WEB 4 PLAN and
WEB 5 PLAN ,
WEB 6 PLAN .
At Alden Hosting we eat and breathe Java! We are the industry leader in providing
affordable, quality and efficient Java web hosting in the shared hosting marketplace.
All our sites run on our Java hosing platform configured for
optimum performance using Java 1.6, Tomcat 6.0.X, MySQL 5.0.x, Apache 2.2.xx and web
application frameworks such as Struts, Hibernate, Cocoon, Ant, etc.
We offer only one type of Java hosting - Private Tomcat. Hosting accounts on the Private
Tomcat environment get their very own Tomcat server. You can start and re-start
your entire Tomcat server yourself.
Running JAR-Packaged Software (The Java™ Tutorials >
Deployment > Packaging Programs in JAR Files)
Running JAR-Packaged Software
Home Page
>
Deployment
>
Packaging Programs in JAR Files
Running JAR-Packaged Software
Now that you've learned how to create JAR files, how do you
actually run the code that you've packaged? Consider these
three scenarios:
- Your JAR file contains an applet that is to be run inside
a browser.
- Your JAR file contains an application that is to be invoked
from the command line.
- Your JAR file contains code that you want to use as an
extension.
This section will cover the first two situations. A separate trail
in the tutorial on the
extension mechanism covers the use of JAR files as extensions.
Applets Packaged in JAR Files
To invoke any applet from an HTML file for running inside a browser,
you need to use the APPLET tag.
For more information, see the
Applets lesson.
If the applet is bundled as a JAR file, the only thing you need to
do differently is to use the ARCHIVE parameter to specify
the relative path to the JAR file.
As an example, let's use (again!) the TicTacToe demo applet that
ships with the JavaTM Development Kit.
The APPLET tag in the HTML file that calls the demo looks like this:
<applet code=TicTacToe.class
width=120 height=120>
</applet>
If the TicTacToe demo were packaged in a JAR file named
TicTacToe.jar,
you could modify the APPLET tag with the simple addition of an
ARCHIVE parameter:
<applet code=TicTacToe.class
archive="TicTacToe.jar"
width=120 height=120>
</applet>
The ARCHIVE parameter specifies the relative path to the JAR file that
contains TicTacToe.class. This example assumes that
the JAR file and the HTML file are in the same directory. If they're
not, you would need to include the JAR file's relative path in the
ARCHIVE parameter's value. For example, if the JAR file was one directory
below the HTML file in a directory called applets, the APPLET
tag would look like this:
<applet code=TicTacToe.class
archive="applets/TicTacToe.jar"
width=120 height=120>
</applet>
JAR Files as Applications
You can run JAR-packaged applications with the Java interpreter. The basic command is:
java -jar jar-file
The -jar flag tells the interpreter
that the application is packaged in the JAR file format. You can only specify one JAR file, which must contain all the application-specific code.
Before you execute this command make sure the runtime environment has an information of which class within the JAR file is the application's entry point.
To indicate which class is the application's entry point,
you must add a Main-Class header to the JAR file's
manifest.
The header takes the form:
Main-Class: classname
The header's value, classname, is the name of the class that's
the application's entry point.
For more information, see the
Setting an Application's Entry Point section.
When the Main-Class is set in the manifest file, you can run the application from the command line:
java -jar app.jar
JAVA, JSP, SERVLETS, TOMCAT, SERVLETS MANAGER,
Private JVM (Java Virtual Machine),
Private Tomcat Server
Alden Hosting offers private JVM (Java Virtual Machine), Java Server Pages (JSP), Servlets, and Servlets Manager with our Web Hosting Plans
WEB 4 PLAN and
WEB 5 PLAN ,
WEB 6 PLAN .
At Alden Hosting we eat and breathe Java! We are the industry leader in providing
affordable, quality and efficient Java web hosting in the shared hosting marketplace.
All our sites run on our Java hosing platform configured for
optimum performance using Java 1.6, Tomcat 6.0.X, MySQL 5.0.x, Apache 2.2.xx and web
application frameworks such as Struts, Hibernate, Cocoon, Ant, etc.
We offer only one type of Java hosting - Private Tomcat. Hosting accounts on the Private
Tomcat environment get their very own Tomcat server. You can start and re-start
your entire Tomcat server yourself.
|