Here is a sample batch file to run a jar file. Just include the classpath of jars needed and replace the name of jar and the class name to run. All the classpath are declared here much simpler than changing the MANIFEST file in jar. For instance the below is to run MyApp.jar class of MyAppScreen. Also useful to run an application that need additional memory by declaring -Xms512M -Xmx1024M displayed at the bottom of the script.
@echo off
if "x%JAVA_HOME%" == "x" (
set JAVA=java
echo JAVA_HOME is not set. Unexpected results may occur.
echo Set JAVA_HOME to the directory of your local JDK to avoid this message.
) else (
set "JAVA=%JAVA_HOME%\bin\java"
echo %JAVA%
)
set CURRENT_DIR=%cd%
rem cd ..
set HOME=%cd%
cd %CURRENT_DIR%
rem set HOME=%CURRENT_DIR%
echo home %HOME%
echo current %CURRENT_DIR%
set MY_CLASSPATH=%HOME%\MyApp.jar
set MY_CLASSPATH=%MY_CLASSPATH%;%HOME%\lib\arq.jar
set MY_CLASSPATH=%MY_CLASSPATH%;%HOME%\lib\antlr-2.7.6.jar
set MY_CLASSPATH=%MY_CLASSPATH%;%HOME%\lib\arq-extra.jar
set MY_CLASSPATH=%MY_CLASSPATH%;%HOME%\lib\asm-3.3.jar
set MY_CLASSPATH=%MY_CLASSPATH%;%HOME%\lib\cglib-2.2.jar
set MY_CLASSPATH=%MY_CLASSPATH%;%HOME%\lib\concurrent.jar
set MY_CLASSPATH=%MY_CLASSPATH%;%HOME%\lib\commons-beanutils-1.7.0.jar
set MY_CLASSPATH=%MY_CLASSPATH%;%HOME%\lib\commons-collections-3.1.jar
set MY_CLASSPATH=%MY_CLASSPATH%;%HOME%\lib\commons-fileupload-1.2.jar
set MY_CLASSPATH=%MY_CLASSPATH%;%HOME%\lib\commons-io-1.3.1.jar
set MY_CLASSPATH=%MY_CLASSPATH%;%HOME%\lib\commons-lang-2.4.jar
set MY_CLASSPATH=%MY_CLASSPATH%;%HOME%\lib\dom4j-1.6.1.jar
echo ========================================================================
echo.
echo My App Utility
echo.
echo HOME: %HOME%
echo.
echo JAVA: %JAVA%
echo.
echo JAVA_OPTS: %JAVA_OPTS%
echo.
echo CLASSPATH: %MY_CLASSPATH%
echo.
echo ========================================================================
echo.
"%JAVA%" -Xms512M -Xmx1024M %JAVA_OPTS% ^
-cp "%MY_CLASSPATH%" my.com.app.MyAppScreen %*
pause
Tuesday, November 29, 2011
Friday, November 25, 2011
Webservice deploy error in jboss 5
If during deployment of webservice jars into jboss 5 it is unable to deploy and the error is something as below
ERROR [[WorkflowServiceImpl]] Servlet.service() for servlet Workflo
wServiceImpl threw exception
java.lang.UnsupportedOperationException: setProperty must be overridden by all s
ubclasses of SOAPMessage
at javax.xml.soap.SOAPMessage.setProperty(SOAPMessage.java:445)
at org.jboss.ws.core.soap.SOAPMessageImpl.<init>(SOAPMessageImpl.java:87
)
Means there are jars missing in the server that is essential to deploying the service. Make sure in the jboss server path
<jboss>\lib\endorsed
the following jars existed
jbossws-native-jaxrpc,
jbossws-native-jaxws,
jbossws-native-jaxws-ext
jbossws-native-saaj
The jars can be found in the latest jboss 6 version. Jboss version 6 and 7 , no such issue with the deployment of web service.
ERROR [[WorkflowServiceImpl]] Servlet.service() for servlet Workflo
wServiceImpl threw exception
java.lang.UnsupportedOperationException: setProperty must be overridden by all s
ubclasses of SOAPMessage
at javax.xml.soap.SOAPMessage.setProperty(SOAPMessage.java:445)
at org.jboss.ws.core.soap.SOAPMessageImpl.<init>(SOAPMessageImpl.java:87
)
Means there are jars missing in the server that is essential to deploying the service. Make sure in the jboss server path
<jboss>\lib\endorsed
the following jars existed
jbossws-native-jaxrpc,
jbossws-native-jaxws,
jbossws-native-jaxws-ext
jbossws-native-saaj
The jars can be found in the latest jboss 6 version. Jboss version 6 and 7 , no such issue with the deployment of web service.
Tuesday, November 8, 2011
Creating a runnable jar file
Creating a runnable jar requires creating a manifest file. Package the classes files into a jar file. Inside the jar create folder META-INF and create file MANIFEST.MF.
The structure is abc.jar/META-INF/MANIFEST.MF
Edit the manifest file by adding the file to run and library jars required for the program as below example.
Main-Class is the class file to run. Make sure it has public static void main(String[] args) in the class to enable it to run.
Class-Path are the library jars.
Manifest-Version: 1.0
Created-By: 1.6.0_07 (Sun Microsystems Inc.)
Main-Class: my.program.gen.GeneratorProcess
Class-Path: lib/antlr-2.7.6.jar lib/cglib-2.2.jar lib/poi-3.7-20101029.jar lib/poi-examples-3.7-20101029.jar lib/poi-ooxml-3.7-20101029.jar lib/poi-ooxml-schemas-3.7-20101029.jar lib/poi-scratchpad-3.7-20101029.jar lib/xml-apis.jar lib/xmlbeans-2.3.0.jar lib/commons-logging.jar lib/xercesImpl.jar lib/iri.jar lib/jaws-bin.jar lib/icu4j_3_4.jar lib/concurrent.jar lib/dom4j-1.6.1.jar
To run the jar an executable .bat file is useful. A sample content of .bat file are as below
java -Xms512M -Xmx1024M -jar Generator.jar
The structure is abc.jar/META-INF/MANIFEST.MF
Edit the manifest file by adding the file to run and library jars required for the program as below example.
Main-Class is the class file to run. Make sure it has public static void main(String[] args) in the class to enable it to run.
Class-Path are the library jars.
Manifest-Version: 1.0
Created-By: 1.6.0_07 (Sun Microsystems Inc.)
Main-Class: my.program.gen.GeneratorProcess
Class-Path: lib/antlr-2.7.6.jar lib/cglib-2.2.jar lib/poi-3.7-20101029.jar lib/poi-examples-3.7-20101029.jar lib/poi-ooxml-3.7-20101029.jar lib/poi-ooxml-schemas-3.7-20101029.jar lib/poi-scratchpad-3.7-20101029.jar lib/xml-apis.jar lib/xmlbeans-2.3.0.jar lib/commons-logging.jar lib/xercesImpl.jar lib/iri.jar lib/jaws-bin.jar lib/icu4j_3_4.jar lib/concurrent.jar lib/dom4j-1.6.1.jar
To run the jar an executable .bat file is useful. A sample content of .bat file are as below
java -Xms512M -Xmx1024M -jar Generator.jar
Subscribe to:
Posts (Atom)