wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes Help running a standalone Java 6 program which is packaged in a war file and deployed in Tomcat 7 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Help running a standalone Java 6 program which is packaged in a war file and deployed in Tomcat 7" Watch "Help running a standalone Java 6 program which is packaged in a war file and deployed in Tomcat 7" New topic
Author

Help running a standalone Java 6 program which is packaged in a war file and deployed in Tomcat 7

James Dekker
Ranch Hand

Joined: Dec 09, 2006
Posts: 215
The issue is that when I run it via Eclipse Juno by clicking on it and "Run as Java Application" it works,
but it needs to be to run in a Linux shell script or at least from the Linux shell.

I need it to append all the jar files from $CATALINA_HOME/webapps/myapp/WEB-INF/lib to my classpath.

Here's my code:



When I cd into $CATALINA_HOME/webapps/myapp/WEB-INF/classes/com/myapp/client issue the following command:



I receive this exception:


When I go to my home dir (/home/devuser) and type this in, it still doesn't work:


Thank you for taking the time to read this... Would appreciate it if someone could assist me.
Steve Luke
Bartender

Joined: Jan 28, 2003
Posts: 4168
    
  21

James Dekker wrote:

When I cd into $CATALINA_HOME/webapps/myapp/WEB-INF/classes/com/myapp/client issue the following command:



Your class is in the package com.myapp.client. The base of this package ($CATALINA_HOME/webapps/myapps/WEB-INF/classes) should be in your classpath, but it is not. You need to add it and call the class by its fully qualified name (com.myapp.client.ClientApp) so Java knows how to locate it - not with the class-only name (ClientApp) - because that looks like the class should be in the default (unnamed) package.



Same problem with the classpath - the base folder for the package is not in the classpath. But this time you are trying to tell Java that the fully qualified name for the class is "$CATALINA_HOME.webapps.myapp.WEB-INF.classes.com.myapp.ClientApp" (except that the environmental variable $CATALINA_HOME is expanded). You have to add the base folder to your classpath AND give the correct fully qualified name of the class you want to run.


And are you sure this application will run on its own? Apps packed in WARs and run through Tomcat are usually webapps and can't be run from the command line like that.


Steve
James Dekker
Ranch Hand

Joined: Dec 09, 2006
Posts: 215
Thanks Steve,

Yes, I was able to get it working by doing this:



Thanks for your great input / feedback!

James
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Help running a standalone Java 6 program which is packaged in a war file and deployed in Tomcat 7
 
Similar Threads
Compiling a class which is dependent on other class
Difficulty in executing
Servlet not not loading axis2 xmlBeans jar
Tomcat unix daemon can't load jsvc tomcat-juli.jar
Is junit.swingui.TestRunner removed from version 4.1 ?