• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Strange reaction with my Java code

 
Ranch Hand
Posts: 111
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello All,

I'm facing a strange behavior with my code
My code is composed of several classes.
Even new in Java, I have tried to code as scrupulous as possible, and have tested  individually each classes.
All seems to work individually as expected.

Now there is a time that you have to put all together, and from here I'm facing following problem
Java Version : jre8
IDE  Eclipse IDE

By running the code (through Eclipse), in order to open a new window, I have to click several times on a "label button" before to have any reaction that new window to popup.
After 2, or 3 attempts finally the new windows popups
FYI: No error are highlighted in Eclipse when I run the code

See image : "Button to Click"

Now when I run the code directly in a cmd window , then I get, "sometimes, but not always" following error

>java -jar PAC-Tool.jar
Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException: input
== null!
       at javax.imageio.ImageIO.read(Unknown Source)
       at pacp.WinMeasurePoints.initialize(WinMeasurePoints.java:194)
       at pacp.WinMeasurePoints.<init>(WinMeasurePoints.java:136)
       at pacp.WinPrime$31.mouseClicked(WinPrime.java:1380)
       at java.awt.Component.processMouseEvent(Unknown Source)
       at javax.swing.JComponent.processMouseEvent(Unknown Source)
       at java.awt.Component.processEvent(Unknown Source)
       at java.awt.Container.processEvent(Unknown Source)
       at java.awt.Component.dispatchEventImpl(Unknown Source)
       at java.awt.Container.dispatchEventImpl(Unknown Source)
       at java.awt.Component.dispatchEvent(Unknown Source)
       at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
       at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
       at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
       at java.awt.Container.dispatchEventImpl(Unknown Source)
       at java.awt.Window.dispatchEventImpl(Unknown Source)
       at java.awt.Component.dispatchEvent(Unknown Source)
       at java.awt.EventQueue.dispatchEventImpl(Unknown Source)



The error is pointing on line 194 in : WinMeasurePoints

After clicking several times the results OK: See image : "Button reaction OK"

What is wrong here ?
Why my code is running sometimes and sometimes not ?

Thanks for your help and eventually suggestion to troubleshoot

Regards

Christian

My Class in question..



Capture.PNG
[Thumbnail for Capture.PNG]
Button to click
CaptureOK.PNG
[Thumbnail for CaptureOK.PNG]
Button reaction OK
 
Christian Klugesherz
Ranch Hand
Posts: 111
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I just discovered a line number shift.

The error is matched on line 176


Correspond also to the the error pointed by running the code in cmd
      at javax.imageio.ImageIO.read(Unknown Source)
       at pacp.WinMeasurePoints.initialize(WinMeasurePoints.java:176)

I'm not able to modify my former message, so reason of this new message
If you can share also a possibility to re-edit a posted message would be helpful

Thanks

Chris
 
Marshal
Posts: 79153
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The line numbers are wrong; if anything is going to go wrong it would be on line 193.
You have some test which throws an illegal argument exception, and that would appear to occur when a null is passed. It would maybe be commoner to throw a null pointer exception, so I looked for something that throws an illegal argument exception. I can't find it, which suggests maybe the actual location of the exception is in different code.
 
Ranch Hand
Posts: 146
4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What is the value in imgPath?  Does the file exist in the location where the program is looking?
 
Norman Radder
Ranch Hand
Posts: 146
4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My test case:
 
Campbell Ritchie
Marshal
Posts: 79153
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Let's look up ImageIO#read. It does in fact throw an illegal argument exception for a null parameter; if the String representing the path to the image has even the tiniest error in, the URL passed to read() will be null.
Check the path to the image very carefully.
 
Christian Klugesherz
Ranch Hand
Posts: 111
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your promt reaction.
Very appreciated.

Relative to file location

By checking the directory I found the issue

D:\Users\kluges1\workspace\pac-tool\src\pacp\images>dir Cycle.*

Répertoire de D:\Users\kluges1\workspace\pac-tool\src\pacp\images

26/01/2017  22:27            58 080 Cycle.PNG
              1 fichier(s)           58 080 octets
              0 Rép(s)  127 647 481 856 octets libres



Windows converted automatically .png in .PNG
I had to force to rename the extension to Cycle.png
What is strange is that Eclipse was permissive to this extension difference..

--> Afterwards no more error.

Nevertheless I have still to push sometimes 2 times the button to have a reaction.

The label button as following


Chris
 
roses are red, violets are blue. Some poems rhyme and some are a tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic