I have an executable jar file that I would like to start from a *.sh script on Ubuntu Linux.
Currently the myapp.sh file looks like this ( error: "nothing happens" ) :
java -jar myapp.jar --start
I also tried ( error: "/bin/sh: 0: Can't open java" ):
/bin/sh java -jar myapp.jar --start
and ( error: "/bin/sh: 0: Can't open java -jar myapp.jar --start" ):
/bin/sh "java -jar myapp.jar --start"
the myapp.sh file has rwx permissions... when I call ./myapp.jar nothing happens.
does somebody has a solution to this issue ?
many thanks in advance.
EDIT 1: Here's my MANIFEST.MF :
Manifest-Version: 1.0
Ant-Version: Apache Ant 1.8.3
Created-By: 1.6.0_38-b05 (Sun Microsystems Inc.)
Class-Path: lib/gf-client.jar lib/security.jar lib/eclipselink-2.3.2.j
ar lib/javax.persistence-2.0.3.jar lib/org.eclipse.persistence.jpa.jp
ql_1.0.1.jar lib/org.eclipse.persistence.jpa.modelgen.processor-2.3.2
.jar lib/javaee-api-6.0.jar lib/LawSuiteFXW.jar lib/AbsoluteLayout.ja
r lib/beansbinding-1.2.1.jar lib/antlr-2.7.7.jar lib/antlr-runtime-3.
3.jar lib/bootstrapconnector.jar lib/commons-codec-1.5.jar lib/common
s-collections-3.2.1.jar lib/commons-compress-1.3.jar lib/commons-dige
ster-1.7.jar lib/commons-email-1.2.jar lib/commons-io-2.4.jar lib/com
mons-lang-2.4.jar lib/commons-lang3-3.1.jar lib/commons-logging-1.1.1
.jar lib/commons-vfs2-2.0.jar lib/glazedlists_java15-1.9-20111127.203
634-11.jar lib/icepdf-core.jar lib/icepdf-viewer.jar lib/jasypt-1.9.0
.jar lib/jcommon-1.0.17.jar lib/jfreechart-1.0.14.jar lib/jhall.jar l
ib/jms.jar lib/joda-time-2.1.jar lib/junit-3.8.1.jar lib/log4j-1.2.15
.jar lib/migcalendarbean.jar lib/PDFRenderer-0.9.1.jar lib/xmlsec-2.0
.jar lib/avalon-framework-api-4.3.1.jar lib/avalon-framework-impl-4.3
.1.jar lib/docx4j-2.8.1.jar lib/fop-1.0.jar lib/itext-2.1.7.jar lib/j
axb-svg11-1.0.2.jar lib/jaxb-xmldsig-core-1.0.0.jar lib/jaxb-xslfo-1.
0.1.jar lib/poi-3.8.jar lib/poi-scratchpad-3.8.jar lib/serializer-2.7
.1.jar lib/stringtemplate-3.2.1.jar lib/wmf2svg-0.9.0.jar lib/xalan-2
.7.1.jar lib/xhtmlrenderer-1.0.0.jar lib/xml-apis-1.3.04.jar lib/xmlg
raphics-commons-1.4.jar lib/poi-ooxml-3.8-20120326.jar lib/poi-ooxml-
schemas-3.8-20120326.jar lib/batik-1.1.1.jar lib/ftp4j-1.7.2.jar lib/
AppleJavaExtensions-1.4.jar lib/swingx-all-1.6.4.jar lib/swingx-beani
nfo-1.6.4.jar lib/pdfbox-1.7.1.jar lib/fontbox-1.7.1.jar lib/jempbox-
1.7.1.jar lib/jai_codec.jar lib/jai_core.jar lib/java-mail-1.4.6.jar
lib/LawSuiteSE.jar
X-COMMENT: Main-Class will be added automatically by build
Main-Class: ch.acme.core.Main
EDIT 2:
I used the following code to start my GUI application:
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
Main m = new Main();
m.setVisible(true);
}
});
}
Removing this to the following, solved the problem. Any ideas ???
public static void main(String[] args) {
Main m = new Main();
m.setVisible(true);
}
Some stuff you might add to help us help you
To be able to start an app from an executable Jar you need:
Define the Main-class inside the manifest Define the class-path inside the manifest and inculde all dependency inside the jar or add -cp to the java call with path to classpath of your dependencies
EDIT: ok from the comments i understand the java command works fine... so your prob is with sh
add this to the top of your sh
and start it by typing ./scriptname.ksh
(replace ksh by sh if you absolutly need to run in sh)
Edit 2: Sample of a Ksh i used:
#!/bin/ksh
JAVA_HOME16=/usr/java16/bin
${JAVA_HOME16}/java -Drunningenv=dev -Dbatch.jdbc.user=${DB2_CODE_USAGER} -Dbatch.jdbc.password=${DB2_MOT_PASSE} -jar ${BASEDIR}/BD_PVFI/bin/spring-batch- conciliation-1.0.0-SNAPSHOT.jar input.desj.file=${INPUTFILE_DESJ}
rc=$?
Try running java with the full path.
Run "which java" for figuring out the full path.
I used the following code to start my GUI application:
EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
Main m = new Main();
m.setVisible(true);
}
});
Removing this, solved the problem. Any ideas ?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.