• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • Devaka Cooray
Saloon Keepers:
  • Ganesh Patekar
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • salvin francis
Bartenders:
  • Ron McLeod
  • Frits Walraven
  • Pete Letkeman

My First Jar File Doesn't Run on Different machines.  RSS feed

 
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello I'm trying to run my first runnable jar file made using eclipse on a different machine.
When I do: java -jar jarName.jar it does not do anything.
I also tried it with java -jar 'jarName".jar

To clarify what I mean by it does not do anything after I press enter no error message is generated (Note I tried putting a try and catch block around my main method).
The terminal appears frozen. I have to press control c to get out of it.

When I run my runnable jar file on my own machine it works as expected.
I also wondered if it had to do with the java versions of the machines.
The machine that compiled with eclipse was running 1.8.0_40
The machine I'm trying to run the jar file on is running java 1.8.0_121

I made a runnable jar file with just a System.out.println and it runs on the other machine so I'm wondering if it's my code.
I'm really not sure what part of my code I should put here, but here's a link to it on github: https://github.com/seal308/aprilBot2/tree/master/src/aprilBot2
Sorry in advance for the frankenstein messy code, I didn't really think I was going anywhere with this.

I'm just wondering why it doesn't run on the other machine and how to fix it. Thanks!
 
Java Cowboy
Sheriff
Posts: 16084
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Most likely it does not have anything to do with differing Java versions, especially because the Java versions are almost the same (different update versions of JDK 8). There would have to be a bug in one of the Java versions that causes this. That's of course possible, but it is much more likely that there is a bug in your own program that causes the problem.

You will have to debug this. The easiest way to get started with that is by putting System.out.println() calls at strategic places in your code so that you can see if the program reaches those places when you run it on the other machine.
 
Sheriff
Posts: 5287
142
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It looks to me that your project is very dependent on local jars and resources.  How did you build your runnable jar?  Have you considered using Maven or some other build program?
 
Knute Snortum
Sheriff
Posts: 5287
142
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You probably should include .settings, .project, and .classpath in your .gitignore file as these files are very system specific and proprietary to Eclipse.  It also exposes the internal structure of your system to the public.
 
Glenn Jayasuriya
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Knute Snortum wrote:It looks to me that your project is very dependent on local jars and resources.  How did you build your runnable jar?  Have you considered using Maven or some other build program?



Hi I built my runnable jar through eclipse. Export ---> Generate runnable Jar ---> package required libraries into runnable Jar.
 
Glenn Jayasuriya
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Knute Snortum wrote:You probably should include .settings, .project, and .classpath in your .gitignore file as these files are very system specific and proprietary to Eclipse.  It also exposes the internal structure of your system to the public.



Ok thank you. Honestly I don't know very much about git and just used the github desktop app on my computer to sync with github.
 
Glenn Jayasuriya
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What I did was run eclipse on another machine. Made a new project with new java files and just copied the java code.
Imported all the jar files which removed all the error messages I was having. (Note also there were messages saying that the source level was wrong but if i just right clicked it resolved those problems for me).
I ran it in eclipse and same thing as with terminal, nothing happened.
So I ran it through the eclipse debugger with breakpoints and found my issues was with the following:


I took this code directly off the Google Spreadsheets API: https://developers.google.com/sheets/api/quickstart/java
I ran the debugger for eclipse on original machine and the eclipse debugger was able to get past this part just fine.
So I'm wondering if the spreadsheet code is what is causing my problem.
Which is a problem because I didn't write it, I don't understand how it works exactly.
From my understanding it uses OAuth consent, through a google wizard you can create a client json file, you add this to your java project to be credentials to the google app.
I made sure to add the json file to the resources folder of the new machine like I did with the old machine but no luck.
I even repeated the process of creating that json file as noted in the link above and included that new json file in the new machine but I had no luck with that as well.
 
Glenn Jayasuriya
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Forgot the mention that when I step over this line it says that "this" was "source not found"
This referred to ScheduledThreadPoolExecutor so I guess it couldn't find ScheduledThreadPoolExecutor
Also mentioned this: java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask@41aa62

This is what I see:
http://imgur.com/a/IvuLh
 
Sheriff
Posts: 23714
50
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That means you haven't configured Eclipse to know where the source code is for the JRE it's using. Just click that debig button which gets you out of that method and back to whatever called it.

It doesn't have anything to do with why your code doesn't run on a different machine -- that would be because the other machine isn't configured the same way as the one you did your testing on.
 
Glenn Jayasuriya
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Paul Clapham wrote:That means you haven't configured Eclipse to know where the source code is for the JRE it's using. Just click that debig button which gets you out of that method and back to whatever called it.

It doesn't have anything to do with why your code doesn't run on a different machine -- that would be because the other machine isn't configured the same way as the one you did your testing on.



Ok in eclipse i went to toolbar and went to Run --> Run Configurations.
I'm just comparing the configurations between the two machines.
The original machine had a runtime JRE of JavaSE-1.7 (Java SE 8 [1.8.0_40
The new machine has a runtime JRE of JavaSE-1.7 (java-8-openjdk-i386)
Besides that the jar files seem to be in the right places for their machines according to the sources section of the run configurations.

Am I looking at the wrong place?
Thanks.
 
Paul Clapham
Sheriff
Posts: 23714
50
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Configuration" covers a lot of territory. Maybe there is supposed to be some other folder somewhere where your code expects to find files. Maybe you have to run the application as an administrator and you aren't. The list could go on indefinitely.

Don't take those guesses seriously, they are based on no evidence. You've got Eclipse running on the target machine? Good. Then run your application and see where exceptions are thrown, for a start. If that doesn't happen then you'll have to start debugging. But without any evidence of a problem you aren't going to be able to solve that problem.
 
Glenn Jayasuriya
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Paul Clapham wrote:"Configuration" covers a lot of territory. Maybe there is supposed to be some other folder somewhere where your code expects to find files. Maybe you have to run the application as an administrator and you aren't. The list could go on indefinitely.

Don't take those guesses seriously, they are based on no evidence. You've got Eclipse running on the target machine? Good. Then run your application and see where exceptions are thrown, for a start. If that doesn't happen then you'll have to start debugging. But without any evidence of a problem you aren't going to be able to solve that problem.



And that's sorta my issue. I've already tried putting try and catch statements and as mentioned above have been running it through the debugger.
It would be easier if it would just tell me an error so I could know what to do in that case.
I might just have to rewrite this from scratch on the target computer.
Still wish I knew what the actual reason was.
 
Knute Snortum
Sheriff
Posts: 5287
142
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you're trying to debug, that is, see the error, I wouldn't put in try/catches that I didn't have to, and then I would always print the stack trace to a log file or the console. 
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!