• 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
  • Junilu Lacar
  • Martin Vashko
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Scott Selikoff
  • salvin francis
  • Piet Souris

Program works in IDE but behaves differently when exported to runnable jar.

 
Ranch Hand
Posts: 50
1
MyEclipse IDE MySQL Database Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So I have been playing around with JDateChooser and I
am wanting to make a scheduler out of it. It would take the input
and store it in a DB. There are criteria for the validity of the submitted
dates, such as no Mondays, no weekends, and it must be for the following
week; i.e. if submitted on week 49 2019 it has to be for week 50 2019,
not week 51 2019, nor week 48 2019 nor week 49 2018, etc.

There are three schedules that an office can submit for the following week.
I worked out the logic to make that happen and it is repeated three times,
once for each schedule and I'm sure that since this is repetitive it should
be made into a seperate class.

I have not yet added database connectivity to it.

My issue is that when I run it in my IDE (Eclipse Jee 2019-09) it works just
as I hoped. However, when I export it as a runnable jar, the submit button does not bring up
the error dialogs when the date is incorrect. It behaves like it has no action event assigned.

the button shows clicking animation but nothing happens.



 
Saloon Keeper
Posts: 2796
367
Android Eclipse IDE Angular Framework MySQL Database TypeScript Redhat Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Ray Gilbert wrote:... when I export it as a runnable jar, the submit button does not bring up the error dialogs when the date is incorrect. It behaves like it has no action event assigned.

the button shows clicking animation but nothing happens.


I tried your code and I see the same behaviour when launched from the IDE as the command line.  This is from the command line:



The only changes I made to your code was to comment-out where the logo is loaded, since I don't have the logo image.
 
Rancher
Posts: 3623
34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

the submit button does not bring up the error dialogs when the date is incorrect.


Are there any error messages?  Open a command prompt window and enter the command: java -jar <THEJARFILENAME>.jar

if there are any error messages, copy the contents of the command prompt window and paste it here.
 
Ray Gilbert
Ranch Hand
Posts: 50
1
MyEclipse IDE MySQL Database Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Norm Radder wrote:

the submit button does not bring up the error dialogs when the date is incorrect.


Are there any error messages?  Open a command prompt window and enter the command: java -jar <THEJARFILENAME>.jar

if there are any error messages, copy the contents of the command prompt window and paste it here.



I ran it from command prompt

The program opens and runs. I am able to choose dates/times. Then when I click the "Submit" button, nothing happens. The Frame just remains
with the selected dares and times. No error dialog appears when there are incorrect dates, nor success dialog when they are correct.
 
Ray Gilbert
Ranch Hand
Posts: 50
1
MyEclipse IDE MySQL Database Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Ron McLeod wrote:

Ray Gilbert wrote:... when I export it as a runnable jar, the submit button does not bring up the error dialogs when the date is incorrect. It behaves like it has no action event assigned.

the button shows clicking animation but nothing happens.


I tried your code and I see the same behaviour when launched from the IDE as the command line.  This is from the command line:



The only changes I made to your code was to comment-out where the logo is loaded, since I don't have the logo image.



You got the the error dialogs when you ran it from command prompt?
 
Ron McLeod
Saloon Keeper
Posts: 2796
367
Android Eclipse IDE Angular Framework MySQL Database TypeScript Redhat Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Ray Gilbert wrote:You got the the error dialogs when you ran it from command prompt?


Yes - ran it from the Windows 10 cmd prompt: D:\TEMP>java -jar JCalendar.jar
 
Ray Gilbert
Ranch Hand
Posts: 50
1
MyEclipse IDE MySQL Database Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Ron McLeod wrote:

Ray Gilbert wrote:You got the the error dialogs when you ran it from command prompt?


Yes - ran it from the Windows 10 cmd prompt: D:\TEMP>java -jar JCalendar.jar



Did you export the jar from IDE?
 
Ron McLeod
Saloon Keeper
Posts: 2796
367
Android Eclipse IDE Angular Framework MySQL Database TypeScript Redhat Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Ray Gilbert wrote:Did you export the jar from IDE?


Yes - these are the settings that I used:



OS: Windows Pro 10 - 64 bit
JRE: 1.8.0_211-b12
Eclipse: 2019-03 (4.11.0)
 
Ranch Hand
Posts: 66
4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Ray Gilbert wrote:


1) one does not extend JFrame but use it in a normal class - extending JFrame (or any class for that matter) is only useful when you change or extend the internal behaviour of the extended class
2) Strings are compared with String.equals(String) - not with "==" operator
3) calling SetVisible(false) followed by dispose() has no effect - you can strip it and just call dispose()

When you get a different result in an IDE environment it always is a good idea to do a "clean" - that means that any compiled class files gets deleted and anything is re-compiled from current source - this way you avoid issues by building an artefact based on older classes not compiled from current source changes.
 
Ray Gilbert
Ranch Hand
Posts: 50
1
MyEclipse IDE MySQL Database Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I got it to work. I had the file and the class named JCalendar but I exported the jar as OmniTrackScheduler. I changed the name of the file and the name of the class to OmniTrackScheduler and it worked.

I don't know why it worked but it did.
 
Ray Gilbert
Ranch Hand
Posts: 50
1
MyEclipse IDE MySQL Database Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Kristina Hansen wrote:

Ray Gilbert wrote: It works the way I did it but I tried
anyway and I got:
"Cannot make a static reference to the non-static method equals(Object) from the type String."

 
Kristina Hansen
Ranch Hand
Posts: 66
4
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Ray Gilbert wrote:I got it to work. I had the file and the class named JCalendar but I exported the jar as OmniTrackScheduler. I changed the name of the file and the name of the class to OmniTrackScheduler and it worked.

I don't know why it worked but it did.


Ray Gilbert wrote:

Kristina Hansen wrote:

Ray Gilbert wrote: It works the way I did it but I tried
anyway and I got:
"Cannot make a static reference to the non-static method equals(Object) from the type String."


Well, it worked cause you forced a clean re-build by change the name - as said: when you got issues from you IDE always try a "clean" as first.
About String comparison: As the mods don't like if I say it directly I try it indirectly: I already noticed it seems like you lack some basics. Not knowing how to correctly compare Strings but try to build such thing screams for more errors you won't understand in the future - I highly recommend you learn basics first before you try to implement some planing tool accessing a database (as the next question highly likely will be some issues with database or how you securely store login data in your code - let me answer is now: you don't!).

Strings compared like this:

That's what the error message you got means: You tried to call equals method as it would be some static in String class - wich, if it would be, needed to paramters instead of just one. But as Object.equals(Object) only has this one parameter it says: "ok, the paramter is what I'm comparing against" - so, how to get the other? Well, you call it on the object you want to comapre.

 
Run away! Run away! Here, take this tiny ad with you:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!