Win a copy of Production-Ready Serverless (Operational Best Practices) this week in the Cloud/Virtualization forum!
  • 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
  • paul wheaton
Sheriffs:
  • Junilu Lacar
  • Paul Clapham
  • Knute Snortum
Saloon Keepers:
  • Stephan van Hulst
  • Ron McLeod
  • Tim Moores
  • salvin francis
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Vijitha Kumara

Cannot open Jar file on particular PC  RSS feed

 
Ranch Hand
Posts: 242
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I was wondering if anyone can test this out to see if it is working on their PC, or if for some reason it will only open on mine because I have all the files on my computer I used to create the program with.  My friend is an assistant director at our summer camp, and needs to use this program I created, but she cannot get it to open and we've tried multiple things.  Before the problem was she just didn't have java downloaded.  Now, she has everything of the 64 bit Java on her Windows 10 PC, but it is just opening a black cmd screen and closing before she has time to read it.

It's worked on other computers I've tried it on.  If you have time, you can go to the link and open the runnable jar on here and see if it works on your computer, or you're getting the same problem. https://www.dropbox.com/sh/n4zi7gttumtyxr1/AACke0J4-BP0rc5-ltRUe58Ra?dl=0

If you don't have time to try opening the file, do you know what would cause one particular client not to be able to open a Jar and have that black screen error come up?  The runnable jar just has to be in the same folder as the lib folder where all the libraries are, but it simply won't open for her.  On 99 of 100 other computers of people using it, it works fine, but I don't know what to tell her.
 
Sheriff
Posts: 24282
55
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Nathan Milota wrote:that black screen error



Could you be a little bit more specific?
 
Nathan Milota
Ranch Hand
Posts: 242
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Paul Clapham wrote:

Nathan Milota wrote:that black screen error



Could you be a little bit more specific?



That's really all it is.  A black sscreen pops up, and it closes a second later.  Nothing specific.
 
Nathan Milota
Ranch Hand
Posts: 242
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Okay, so I had her run the file from the command prompt, and it is getting a error that it cannot find or load the main class.  Class not found exception.
 
Rancher
Posts: 3983
47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What command is being used to run it from the command line?
And what exact error is occurring?
Copy and paste them both here would be easiest.
 
Rancher
Posts: 1170
18
Firefox Browser Hibernate IntelliJ IDE Java MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Most likely it's a file association problem caused by other programs. What is bin verry helpfull for me in the past is JarFix
 
Saloon Keeper
Posts: 9986
206
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The Jar looks fine. Like Dave said, we need to know what command you used to try and run it, and what error message it gave.
 
Daniel Demesmaecker
Rancher
Posts: 1170
18
Firefox Browser Hibernate IntelliJ IDE Java MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I had the exact same problem in this post
 
Dave Tolls
Rancher
Posts: 3983
47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's not necessarily the same problem, as the OP is able to run the jar file on other machines, but not this one.
 
Nathan Milota
Ranch Hand
Posts: 242
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The error is in the picture here.  The command used is rather irrelevant though, as it has the same problem when clicking on it as well, but the black screen terminates before she can read it.
classnotfoundexception.jpg
[Thumbnail for classnotfoundexception.jpg]
 
Daniel Demesmaecker
Rancher
Posts: 1170
18
Firefox Browser Hibernate IntelliJ IDE Java MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It runs on my computer... Why are you us a textfield to select a date? I asume it's maded with javaFx or swing?
Stupid question, but... She has java installed right?
 
Saloon Keeper
Posts: 2182
92
Eclipse IDE Google Web Toolkit Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Daniel Demesmaecker wrote:...She has java installed right?


The error "Error:could not find or load main class" indicates that java is installed right ?
I guess that somehow the classpath on that windows machine might be changed or altered to point somewhere else ?

OP, can you share what happens when run the following command:
 
Saloon Keeper
Posts: 2471
317
Android Angular Framework Eclipse IDE Java Linux MySQL Database Redhat TypeScript
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Windows console wrote:Error: Could not find or load main class C:\ ... \Cabin Assigner Pro.jar


This is the kind of error you would get if the -jar option was missing from the command line.
 
Bartender
Posts: 20562
120
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Nathan Milota wrote:

Paul Clapham wrote:

Nathan Milota wrote:that black screen error



Could you be a little bit more specific?



That's really all it is.  A black sscreen pops up, and it closes a second later.  Nothing specific.



Windows does this when it tries to execute something that it thinks needs stdio. Which the "java" command would. The window opens, program terminates, window closes.

Best way to diagnose the problem is to open a "permanent" command prompt ("DOS") window and type in the command that's supposed to be executed. You can check the Windows Desktop file associations to make sure it's really doing what you think it's doing. Since a permanent window won't close after the command executes (just prompts for the next command), you should be able to see any error messages.

A leading suspect is definitely a case where the "working directory" for the JAR as defined by the Windows Desktop config isn't where the JAR really is. Another case would be if the command associated with the ".jar" suffix doesn't match what you want - and I should note that to me, "opening" a JAR would mean launching something like WinZip to see what's in the JAR. But from the sound of it, this particular exercise wants to execute the JAR.
 
Tim Holloway
Bartender
Posts: 20562
120
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just a thought. Another likely way to have this break between systems is for the Java executable to not be located in the expected place. Here again, the Windows Desktop file associate would be at fault.
 
Daniel Demesmaecker
Rancher
Posts: 1170
18
Firefox Browser Hibernate IntelliJ IDE Java MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Ron McLeod wrote:

Windows console wrote:Error: Could not find or load main class C:\ ... \Cabin Assigner Pro.jar


This is the kind of error you would get if the -jar option was missing from the command line.


Then it would still run when double clicked, I didn't run it from the commandline and it worked, I keep saying try using jarfix, it might help and if it dosn't it wont hurt
 
Ron McLeod
Saloon Keeper
Posts: 2471
317
Android Angular Framework Eclipse IDE Java Linux MySQL Database Redhat TypeScript
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Ron McLeod wrote:

Windows console wrote:Error: Could not find or load main class C:\ ... \Cabin Assigner Pro.jar


This is the kind of error you would get if the -jar option was missing from the command line.


Use a Windows command window (not PS)  to check the file extension association for .jar, and then check the command line associated with type to see what it is doing.

For example, on my workstation:
 
Ron McLeod
Saloon Keeper
Posts: 2471
317
Android Angular Framework Eclipse IDE Java Linux MySQL Database Redhat TypeScript
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Daniel Demesmaecker wrote:I keep saying try using jarfix, it might help and if it dosn't it wont hurt


If it were me, I would first understand the problem, and then apply the appropriate fix.
 
Daniel Demesmaecker
Rancher
Posts: 1170
18
Firefox Browser Hibernate IntelliJ IDE Java MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If jarfix works it has to do with file association
 
Nathan Milota
Ranch Hand
Posts: 242
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Daniel Demesmaecker wrote:It runs on my computer... Why are you us a textfield to select a date? I asume it's maded with javaFx or swing?
Stupid question, but... She has java installed right?



It was made in Swing.  It was more a program I made when studying the basics of programming figuring out how the functions work.  I'm not doing improvements on it beyond what it has, as I'm going to be reforming it into a web service soon.  
 
Nathan Milota
Ranch Hand
Posts: 242
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally, the problem was she asked me how to actually open the program, which I was kind of surprised, as all you do is click it.  However, she didn't have Java on her computer, which I was a little surprised as to how she has even been able to use her computer for much of anything without Java on it.  Then, it turns out she only uses Firefox, which doesn't use Java.  When she downloaded Java, she downloaded and updated to the latest version as many times as possible, and now she has everything on her computer that she needs to run any Java program, and is now getting the class not found exception when trying to open it.   Her computer is so far the only one of many computer that have not been able to run the Jar, and she is the one that needs to use the program for our camp.
 
Ranch Hand
Posts: 138
5
MS IE Notepad Suse
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok - so I de-compiled you code - found this:

even if it's only running on localhost - at least run mysql_secure_installation and set a root password
further: you can remove any line of this

mysql driver is JDBC4 complient - this means, as long as its in classpath it registers itself with serviceloader - no need for Class.forName()
current driver is v8 - wich is com.mysql.cj.jdbc.Driver - the v5 you use is obsolete
you wasting lots of database resources - as you open a new connection on every request - but never proper close them - that's not how to do - if you want to use a sql-database you create ONE and only ONE connection at startup and close it cleanly at exit - also each resultset and statement has to be close as long as you don't use try-with-resources wich uses autoclose

i dont know lic4j - but is it right that some master-key is in source?



from DNSSEC i know 03 010001 is for 65537 - but this SHA512withECDSA cofuses me - what strange kind of format is this?

overall - very advanced project with beginner mistakes somewhat not matching the question
 
Paul Clapham
Sheriff
Posts: 24282
55
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Could I suggest that, since of course you can't run this program without Java installed, that you try a different way of running it? Instead of expecting that "Cabin Assigner Pro.jar" will run the jar file, which apparently isn't always the case, why not try



instead? When you install Java on a Windows machine you know that the "java" command will be mapped to the appropriate java.exe. Whereas you don't know that the ".jar" extension will be mapped to whatever it is that runs executable jars.

The other advantage of that is that the "java" command gives you a command-line screen which doesn't go away when your Swing app runs, so if the app throws an exception you will see the stack trace.
 
Tim Holloway
Bartender
Posts: 20562
120
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Matt Wong wrote:if you want to use a sql-database you create ONE and only ONE connection at startup and close it cleanly at exit



Mostly. In the case of web applications, you configure the webapp server for a database Connection Pool, obtain a Connection from the pool only when you're about to do something that needs a Connection, then close() the Connection to return it to the pool as soon as you can after using the Connection (never hold onto Connections in a web application!)

To expand on Paul's suggestion, you can include a BAT file with the java -jar command in it along with the JAR when you ship it. Clicking on the BAT icon should then result in what he said. Although if you are doing that on a known good setup, you can eliminate the pop-up black window by adding a ">NULL:" to the java command line.

Finally, since this app is expecting to find a MYSQL server on the system it's executed on, I trust that such as server has been installed and configured - including setting it up to listen on port 3306 instead of just internal plumbing channels (which are the default, if I'm not mistaken).
 
Nathan Milota
Ranch Hand
Posts: 242
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the suggestions on the database, but that is all irrelevant to the post, because that's not what is keeping it from opening properly.

I already know the problem is the class not found exception, but I'm just trying to figure out why it is not opening on that particular computer when it opens on every other computer I've tried it on.  

I only wanted to use dos to see the error, but if she has to go into dos and type in a bunch of text every time she uses the program, she will probably lose interest.  I'm trying to figure out how to get it to open with a click of a button on the jar without any errors, as this problem is not happening with any other PC.
 
Nathan Milota
Ranch Hand
Posts: 242
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Matt Wong wrote:ok - so I de-compiled you code - found this:

even if it's only running on localhost - at least run mysql_secure_installation and set a root password
further: you can remove any line of this

mysql driver is JDBC4 complient - this means, as long as its in classpath it registers itself with serviceloader - no need for Class.forName()
current driver is v8 - wich is com.mysql.cj.jdbc.Driver - the v5 you use is obsolete
you wasting lots of database resources - as you open a new connection on every request - but never proper close them - that's not how to do - if you want to use a sql-database you create ONE and only ONE connection at startup and close it cleanly at exit - also each resultset and statement has to be close as long as you don't use try-with-resources wich uses autoclose

i dont know lic4j - but is it right that some master-key is in source?



from DNSSEC i know 03 010001 is for 65537 - but this SHA512withECDSA cofuses me - what strange kind of format is this?

overall - very advanced project with beginner mistakes somewhat not matching the question



The reason this project has a lot of beginner errors is because I started making it as a beginner, so if you start going through the code, you'll see that many of the methods seem to be more advanced with less coding errors than others.  I am not planning on going back and changing every method to make it cleaner code, as one class has over 2000 lines of code on it.  

The main reason is why the Jar won't open by clicking on it, and the JDBC or licensing class has absolutely nothing to do with that.  She won't be using the database portion of it.  That's just after I start a web service, I want to have this as an option to add people to it.  
 
Stephan van Hulst
Saloon Keeper
Posts: 9986
206
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We want you to have your client execute that command on their system so we can debug it.

If it works, then clearly java is installed and is working, and then the default file association for .jar is not configured to run the correct command. In that case the fix that Daniel proposed would likely solve your problems.
 
Nathan Milota
Ranch Hand
Posts: 242
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks everyone.  I'm not sure when she will have a chance to try it again.  What I'm likely going to do is try and fix it for her on her computer next time I see her if she doesn't make use of the JarFix to see if that solves the problem.
 
Matt Wong
Ranch Hand
Posts: 138
5
MS IE Notepad Suse
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the main reason i decompiled and look through your code was
1) never run code you dont know or trust
2) check to see if it does something odd
3) i already ran into some copy'n'paste trick cause someone has hidden the code outside the sites layout and i didnt noticed it in my editor
i jsut found these "wtf" lines by simple scrolling through it scanning it for some unwated lines
 
Nathan Milota
Ranch Hand
Posts: 242
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The JarFix did it.

The program is fully functional as we need it.  It may have some messy code that the user doesn't see, but the important thing is that it all works.  I was making this project when I was new to programming and only had 2 classes, so there are a lot of ways I'd do things differently now.
 
Daniel Demesmaecker
Rancher
Posts: 1170
18
Firefox Browser Hibernate IntelliJ IDE Java MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not to be cocky, but I knew it would...
 
Stephan van Hulst
Saloon Keeper
Posts: 9986
206
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's called being cocky.
 
I was born with webbed fish toes. This tiny ad is my only friend:
global solutions you can do in your home or backyard
https://coderanch.com/t/708587/global-solutions-home-backyard
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!