0

I compiled my program into a jar file and my folder contains three files:

config.ini
NotifyService.bat
NotifyService.jar

In my NotifyService.bat:

java -jar NotifyService.jar
pause

When I double clicked on the bat file,it will auto run the jar file for me on command prompt.I could run the jar file with no issues on my machine.I copied the exact same files and run it remotely on a different pc,also works with no issues.

Now I tried with a third machine and it throws an error: Error:Invalid or corrupt jarfile NotfiyService.jar when I tried to run it.

Is there anything I should be looking at to diagnose this issue?

From what I can tell,they all shared the same configuration settings and are all running on windows.

Edit:

So from further checking,it seems the working machines are running java 1.8 while the non-working machines are using 1.7. I guess this is the reason it does not recognize the jar file. Is there a way to use the 1.7 machine to run the 1.8 jar file?

Daredevil
  • 1,672
  • 3
  • 18
  • 47
  • your jar file contains a jar file .... why? – Stultuske May 21 '19 at 09:47
  • Show you NotifyService.bat file – Sambit May 21 '19 at 09:47
  • @Stultuske What do you mean my jar file contains jar file? – Daredevil May 21 '19 at 09:50
  • I mean : "and my jar file contains three files: **.ini, **.bat, **.jar" – Stultuske May 21 '19 at 09:53
  • @Stultuske My bad,i meant to say folder instead,not jar file – Daredevil May 21 '19 at 09:53
  • have you checked whether the environment settings for both machines are the same? – Stultuske May 21 '19 at 09:56
  • Can you specify exactly which environment? Because they are both running on java 1.7. My first thing I thought would is because it needed a `meta-inf` folder? But it shouldn't be the case since it worked on other pc without the folder – Daredevil May 21 '19 at 09:56
  • In the third system, check whether java is there or not, then check the path mentioned if any .properties or ini file. If you show your .bat file, it will good. Before executing .bat file, you can check by running the jar file with command java -jar – Sambit May 21 '19 at 09:59
  • @Sambit I did run the jar file on command as well and same error shows. Not sure what else to look for. – Daredevil May 21 '19 at 10:00
  • So from what I see,the two machines that could run the jar file hava Java 1.8 while the non working machine has 1.7. Could this be a cause? – Daredevil May 21 '19 at 10:07
  • First go to the machine and run the jar file using command prompt with java -jar .jar. If it does not work, then we will have to see other areas. – Sambit May 21 '19 at 10:08
  • If you post the complete error, we will be able to help you – Sambit May 21 '19 at 10:10
  • Dude,I already posted the complete error above. – Daredevil May 21 '19 at 10:10
  • What is your main class name ? Run the command with your main class name as java -jar NotifyService.jar . Try this one. Do not run the .bat file for the time being – Sambit May 21 '19 at 10:17
  • I suspect this is due to different version of java. you can see my edited post explanation. How do i solve it? – Daredevil May 21 '19 at 10:17
  • Build the application in lower version of java and run in a system having same or higher version of java. – Sambit May 21 '19 at 10:21
  • How do I build the jar in intellij to lower version? – Daredevil May 21 '19 at 10:22
  • take look at https://stackoverflow.com/questions/25115059/intellij-compile-for-java-7-jre-using-java-8-sdk – Raso May 21 '19 at 10:28

0 Answers0