• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

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

 
Ranch Hand
Posts: 126
1
MyEclipse IDE MySQL Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.



 
Marshal
Posts: 4017
549
Android Eclipse IDE TypeScript Redhat MicroProfile Quarkus Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 4893
38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 126
1
MyEclipse IDE MySQL Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 126
1
MyEclipse IDE MySQL Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Marshal
Posts: 4017
549
Android Eclipse IDE TypeScript Redhat MicroProfile Quarkus Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 126
1
MyEclipse IDE MySQL Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Marshal
Posts: 4017
549
Android Eclipse IDE TypeScript Redhat MicroProfile Quarkus Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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)
 
Rancher
Posts: 144
9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 126
1
MyEclipse IDE MySQL Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 126
1
MyEclipse IDE MySQL Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Rancher
Posts: 144
9
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.

 
Aaaaaand ... we're on the march. Stylin. Get with it tiny ad.
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic