Zolf
asked on
Cannot run Jar file
Can you please select that as text and post it as text (code)? Or even easier, he he - attach the bat file ;)
ASKER
Thanks for your comments.
I could not attach the bat file, so i have copied it here
start javaw -cp behsa-1.0-SNAPSHOT.jar;dependency/poi-scratchpad-3.14.jar;dependency/javax.inject-1.jar;dependency/reactfx-1.4.1.jar;dependency/commons-codec-1.10.jar;dependency/commons-dbcp-1.4.jar;dependency/curvesapi-1.03.jar;dependency/guice-4.0.jar;dependency/controlsfx-8.40.10.jar;dependency/aopalliance-1.0.jar;dependency/guice-multibindings-4.0.jar;dependency/stax-api-1.0.1.jar;dependency/guava-16.0.1.jar;dependency/xmlbeans-2.6.0.jar;dependency/commons-pool-1.5.4.jar;dependency/poi-ooxml-schemas-3.14.jar;dependency/poi-ooxml-3.14.jar;dependency/jcalendar-1.4.jar;dependency/slf4j-simple-1.7.21.jar;dependency/slf4j-api-1.7.21.jar;dependency/poi-3.14.jar;dependency/jtds-1.3.1.jar com.behsa.Main
I could not attach the bat file, so i have copied it here
start javaw -cp behsa-1.0-SNAPSHOT.jar;dependency/poi-scratchpad-3.14.jar;dependency/javax.inject-1.jar;dependency/reactfx-1.4.1.jar;dependency/commons-codec-1.10.jar;dependency/commons-dbcp-1.4.jar;dependency/curvesapi-1.03.jar;dependency/guice-4.0.jar;dependency/controlsfx-8.40.10.jar;dependency/aopalliance-1.0.jar;dependency/guice-multibindings-4.0.jar;dependency/stax-api-1.0.1.jar;dependency/guava-16.0.1.jar;dependency/xmlbeans-2.6.0.jar;dependency/commons-pool-1.5.4.jar;dependency/poi-ooxml-schemas-3.14.jar;dependency/poi-ooxml-3.14.jar;dependency/jcalendar-1.4.jar;dependency/slf4j-simple-1.7.21.jar;dependency/slf4j-api-1.7.21.jar;dependency/poi-3.14.jar;dependency/jtds-1.3.1.jar com.behsa.Main
That's an odd command line – it looks like absolutely nothing happened with no errors. Is that actually what happens (or what doesn't happen)?
Can you please try that without the 'start'?
Can you please try that without the 'start'?
ASKER
when I run that bat nothing happens
As @CEHJ mentioned, this command looks very strange.
I might be wrong, as it's been decades since I used Windows...
As best I recall ";" separates commands, so the command above really means...
Run your string above as many commands, where each ";" breaks the string + runs the dependency/... path as a command, which will almost certainly fail.
Maybe this is somehow different today.
Normally I'd approach this by using a custom $CLASSPATH setting.
I might be wrong, as it's been decades since I used Windows...
As best I recall ";" separates commands, so the command above really means...
Run your string above as many commands, where each ";" breaks the string + runs the dependency/... path as a command, which will almost certainly fail.
Maybe this is somehow different today.
Normally I'd approach this by using a custom $CLASSPATH setting.
Can you please save this as z.bat and tell me what happens when you run it?
echo Hi Zolf
ASKER
C:\behsa>echo Hi Zolf
Hi Zolf
C:\behsa>
As best I recall ";" separates commands, so the command above really means...
On *nix shells yes. On Windows it's the path separator and thus is correct for a classpath. I think there could be something going on with non-execution of batch files, period
ASKER
C:\behsa>z.bat
C:\behsa>echo Hi Zolf
Hi Zolf
C:\behsa>
OK, my theory was wrong ;)
Can you (I hope you know how to do copy and paste with cmd.exe) copy that entire command, paste it into the terminal and execute it manually?
Can you (I hope you know how to do copy and paste with cmd.exe) copy that entire command, paste it into the terminal and execute it manually?
ASKER
I am following Reamme instruction to prepare the app, below I have copied the instruction
# create a properties file `~/.config/behsa/behsa.properties`
example:
dbhost=192.168.1.100
dbname=dbform
username=sa
password=321321
#output.dir should be absolute path
output.dir=/home/techno/.config/behsa/output
#if you are facing a problem viewing Excel files, you can set path to Excel viewer manually
excel.viewer=/usr/bin/soffice
bartender.host=192.168.1.106
bartender.serials.port=1024
bartender.aggregs.port=1025
## build the app
cd behsatnt
mvn clean package
## run on windows
* build the app as on previous point
* create a folder `C:/behsa`
* copy `$project_root/behsa.bat`, `$project_root/target/dependency`, `$project_root/target/behsa-1.0-SHAPSHOT.jar` to `C:/behsa` folder
* create the properties file as on this README
* create a shortcut on Windows Desktop and point it to `C:/behsa/behsa.bat`
* double click the shortcut
## run via webstart
you run a webserver somewhere in your net. Create a folder `behsa` so that it's available as
`http://WEBSERVER_ADDRESS:PORT/behsa` and this address is mapped to, say `/var/lib/webserver/behsa/`.
* copy `src/main/resources/behsa.jnlp` to `/var/lib/webserver/behsa/`
* copy `depsigned/*` to `/var/lib/webserver/behsa/dependency/`
* build the app as on previous point
* copy `target/behsa-1.0-SNAPSHOT.jar` to `/var/lib/webserver/`
* start the app on any machine from your net: `javaws http://WEBSERVER_ADDRESS_PORT/behsa/behsa.jnlp`
## get updates and rebuild
cd behsatnt
git pull
mvn clean package
ASKER
ASKER
CEHJ
I have a feeling it has to do with this .config folder, it cannot read this file to get db connection
I have a feeling it has to do with this .config folder, it cannot read this file to get db connection
OK. We might have a MAX_PATH issue possibly. Hang on…
Not sure this will be much better, but have a try:
It's got to be said though, that since you're using Maven, you should be starting with exec:java. See example of that in pom.xml below:
set D=dependency
start javaw -cp behsa-1.0-SNAPSHOT.jar;%D%/poi-scratchpad-3.14.jar;%D%/javax.inject-1.jar;%D%/reactfx-1.4.1.jar;%D%/commons-codec-1.10.jar;%D%/commons-dbcp-1.4.jar;%D%/curvesapi-1.03.jar;%D%/guice-4.0.jar;%D%/controlsfx-8.40.10.jar;%D%/aopalliance-1.0.jar;%D%/guice-multibindings-4.0.jar;%D%/stax-api-1.0.1.jar;%D%/guava-16.0.1.jar;%D%/xmlbeans-2.6.0.jar;%D%/commons-pool-1.5.4.jar;%D%/poi-ooxml-schemas-3.14.jar;%D%/poi-ooxml-3.14.jar;%D%/jcalendar-1.4.jar;%D%/slf4j-simple-1.7.21.jar;%D%/slf4j-api-1.7.21.jar;%D%/poi-3.14.jar;%D%/jtds-1.3.1.jar com.behsa.Main
It's got to be said though, that since you're using Maven, you should be starting with exec:java. See example of that in pom.xml below:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.technojeeves.bat</groupId>
<artifactId>bat</artifactId>
<name>bat</name>
<version>1.0-SNAPSHOT</version>
<dependencies>
<!-- Logback
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.6.6</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.0.9</version>
</dependency>
-->
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.4.0</version>
<configuration>
<mainClass>com.technojeeves.bat.App</mainClass>
</configuration>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>${maven.compiler.source}</source>
<target>${maven.compiler.target}</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-shade-plugin</artifactId>
<version>3.1.0</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<manifestEntries>
<Main-Class>com.technojeeves.bat.App</Main-Class>
<Build-Number>1</Build-Number>
</manifestEntries>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>Central Repository</id>
<url>https://repo.maven.apache.org/maven2</url>
</repository>
</repositories>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
</project>
ASKER
CEHJ
Lets try to run the app from the eclipse first and see if it runs from there. I setup the app in eclipse and when I try to run the app I get this error. Can you please help me, I know I am jumping around.
Lets try to run the app from the eclipse first and see if it runs from there. I setup the app in eclipse and when I try to run the app I get this error. Can you please help me, I know I am jumping around.
[JavaFX Application Thread] INFO com.behsa.gui.SerialOrderForm - glyph Glyph@440245ba[styleClass=label glyph-font]'' 0.0 0.0 PLUS 14.0 null
Exception in Application start method
[JavaFX Application Thread] INFO com.behsa.DataAccess - Closing database
[JavaFX Application Thread] INFO com.behsa.DataAccess - Closed
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:389)
at com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:328)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:767)
Caused by: java.lang.RuntimeException: Exception in Application start method
at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:917)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$155(LauncherImpl.java:182)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.RuntimeException: ControlsFX Error: ControlsFX 8.40.10 requires at least Java Version 8 Update 40
at impl.org.controlsfx.version.VersionChecker.doVersionCheck(VersionChecker.java:96)
at org.controlsfx.control.ControlsFXControl.<init>(ControlsFXControl.java:35)
at org.controlsfx.control.StatusBar.<init>(StatusBar.java:82)
at com.behsa.gui.StatusBar.getRootNode(StatusBar.java:21)
at com.behsa.gui.MainPane.getRootNode(MainPane.java:55)
at com.behsa.Main.start(Main.java:80)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$162(LauncherImpl.java:863)
at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$175(PlatformImpl.java:326)
at com.sun.javafx.application.PlatformImpl.lambda$null$173(PlatformImpl.java:295)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$174(PlatformImpl.java:294)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$148(WinApplication.java:191)
... 1 more
Exception running application com.behsa.Main
Can you please attach your pom.xml
And yes, you definitely have runtime errors too
And yes, you definitely have runtime errors too
OK, more in a few minutes, I have something that must be done. In the meantime, try to sort out your runtime errors.
Look also at lines 25-32 of my pom. You should have those in yours so you can invoke exec:java and start your app
Look also at lines 25-32 of my pom. You should have those in yours so you can invoke exec:java and start your app
ASKER
OK, more in a few minutes, I have something that must be done.cheers mate
In the meantime, try to sort out your runtime errors.I managed to resolve that issue. It seems to be the version of controlfx and java version conflict. I updated the controlfx version from 8.40.10 to 8.40.11 and I am able to run the app in eclipse
Look also at lines 25-32 of my pom.it seems you did not attache the pom. I will wait
it seems you did not attache the pom. I will waitI pasted it in THIS
Can you please link to the source: please cd to the project directory then:
jar cvfM src.zip pom.xml src
and post a link to src.zip
ASKER
I did not understand. Do you mean I send you the src folder??
I mean do what i asked: run that command and please post a link to the resulting src.zip file
ASKER
can i email you the src.zip
ASKER
CEHJ sent you the link in EE message
Got it
Here you go: https://drive.google.com/file/d/1aZkIL-8idL1BUX9vCRuGUJxtk6EcZGcq/view?usp=sharing
You should be able to run that with
as it's a shaded jar. I've included the altered pom.xml. Back up your own and copy mine into your project to overwrite your original
Your execution args are numerous so it will be a bit tricky to use exec:java but it could probably be done. Check Maven's exec.args
Oh and please let me know as soon as you've downloaded it as it takes up quite a bit of space and should go ;)
PS: I had to comment out the jarsigning stage as my environment is different. You need to reinstate that in the pom
You should be able to run that with
java -jar <the snapshot>
as it's a shaded jar. I've included the altered pom.xml. Back up your own and copy mine into your project to overwrite your original
Your execution args are numerous so it will be a bit tricky to use exec:java but it could probably be done. Check Maven's exec.args
Oh and please let me know as soon as you've downloaded it as it takes up quite a bit of space and should go ;)
PS: I had to comment out the jarsigning stage as my environment is different. You need to reinstate that in the pom
ASKER
Thanks, can you please give me access to that file
ASKER
Managed to download the jar file. Do I unzip it or run the jar
You can run it, but see above about pom.xml
ASKER
double clicking on the bat file I managed to run the app. But can you please tell me what do i need to do with my pom file. What was the issue, can you please elaborate. appreciate your help
Well if it's working, you probably don't need to do anything with it ;). I don't quite get why it's suddenly working though…
ASKER
You can only do
java -jar
with my jar to run it. That's not my jar is it?
ASKER
with my jar to run it. That's not my jar is it?I was running your jar
Obviously you have to put the name of the jar file in as the argument - what would you be running otherwise? ;)
You also didn't answer my question about whether that's my jar or not
You also didn't answer my question about whether that's my jar or not
ASKER
let me restart my machine as I am not able to delete the snapshot jar
Keep my jar in a different place entirely - it's entirely self-sufficient and shouldn't be confused with yours
ASKER
ok I am back.
After restarting windows I managed to del the snapshot jar file. Then I again run this cmd
Now I want to know what is the issue with my pom and do i just replace my pom with the pom you provided above??
After restarting windows I managed to del the snapshot jar file. Then I again run this cmd
mvn clean package
the jar was created and when I compare that to your jar the size of my jar is 110KB and yours is 22,196KB. So, it seems my jar is not getting packed with all the jars. guessing!!Now I want to know what is the issue with my pom and do i just replace my pom with the pom you provided above??
ASKER
ASKER
I've included the altered pom.xml. Back up your own and copy mine into your project to overwrite your originalCan you please provide the pom file again so i can again run the
mvn clean package
with your pom.xml and do I need to sign the jars??
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
CEHJ,
Thanks so much managed to run it as expected. Appreciate your time and help!!.
Thanks so much managed to run it as expected. Appreciate your time and help!!.
That's good. As to whether you need to sign it or not - I don't know. If you're not sure, you probably don't ;)
:)