?
Solved

Program detects REsources when runned through JBuilder but not after it is deployed to a jar file

Posted on 2004-09-13
21
Medium Priority
?
202 Views
Last Modified: 2010-03-31
I developed a program that uses Images located  in mypackage.images. The JBuilder identified the PNG images in the project contents. When I run the program through JBuilder it works fine. After deployemt though when I try to run the Native Executable it does find the images
Why? This classpath thing confuses me so much
0
Comment
Question by:Trooper80
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 9
  • 8
  • 3
  • +1
21 Comments
 
LVL 9

Expert Comment

by:Venci75
ID: 12044902
how do you load your images?
Also - what do you mean by 'deplyment'? Do you mean deployment on an application server?
Please, be more concrete.
0
 
LVL 1

Author Comment

by:Trooper80
ID: 12044992
ImageIcon imgMain = new ImageIcon( this.getClass( ).getResource(
        "images/logo.PNG" ) );

This CLASS is found in the "javollo" package
***The image is in the "javollo/images/logo.PNG"(loaded through the MainPane.class)

When I run the program through JBuilder it runs OK. When (deploy) the classes into a JAR file and create a Native Executable it even adds the images in the JAR file but it does not display them.
When I run the console EXE file I get
java.lang.NullPointerException
        at javax.swing.ImageIcon.<init>(Unknown Source)
        at javollotest.MainPane.jbInit(MainPane.java:43) //at this line I have ***above
        at javollotest.MainPane.<init>(MainPane.java:28)
        at javollotest.MainFrame.<init>(MainFrame.java:28)
        at javollotest.JavOLLO.<init>(JavOLLO.java:11)
        at javollotest.JavOLLO.main(JavOLLO.java:42)
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 12044997
How are you setting the classpath? Are you using a jar?
0
Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

 
LVL 86

Expert Comment

by:CEHJ
ID: 12045013
Make sure javollo is set as a classpath in the manifest. Use

new ImageIcon( this.getClass( ).getResource(
       "/images/logo.PNG" ) );


0
 
LVL 1

Author Comment

by:Trooper80
ID: 12045017
Sorry
***at the line 43 of my source I have this code:
 imgMain = new ImageIcon( this.getClass( ).getResource(
        "images/logo.PNG" ) );

and I get:

java.lang.NullPointerException
        at javax.swing.ImageIcon.<init>(Unknown Source)
        at javollotest.MainPane.jbInit(MainPane.java:43) //at this line I have ***above
        at javollotest.MainPane.<init>(MainPane.java:28)
        at javollotest.MainFrame.<init>(MainFrame.java:28)
        at javollotest.JavOLLO.<init>(JavOLLO.java:11)
        at javollotest.JavOLLO.main(JavOLLO.java:42)

at javollotest.MainPane.jbInit(MainPane.java:43)
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 12045023
(and of course that path is case-sensitive)
0
 
LVL 1

Author Comment

by:Trooper80
ID: 12045050
Setting the classpath where?
The output path u mean?
How to set the javollo as a classpath in the Manifest?
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 12045058
It might help too if you tell us what your package declaration is in your code
0
 
LVL 35

Expert Comment

by:TimYates
ID: 12045066
Are you sure the images are in the jar file?
0
 
LVL 1

Author Comment

by:Trooper80
ID: 12045114
package javollotest;

sorry I forgot the test

So how to include it in the MANIFEST?
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 12045127
>>How to set the javollo as a classpath in the Manifest?

See http://mindprod.com/jgloss/jar.html

0
 
LVL 35

Expert Comment

by:TimYates
ID: 12045146
Or

imgMain = new ImageIcon( this.getClass( ).getResource( "/javollo/images/logo.PNG" ) );

should work...
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 12045166
>>package javollotest;

If that's your declaration, you need to include the directory that contains that in Class-Path, not javaollotest itself
0
 
LVL 1

Author Comment

by:Trooper80
ID: 12045260
How to do that?
0
 
LVL 35

Accepted Solution

by:
TimYates earned 80 total points
ID: 12045296
Have you tried:

imgMain = new ImageIcon( this.getClass( ).getResource( "/javollo/images/logo.PNG" ) );

?
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 12045302
>>How to do that?

The above link i posted tells you how to do that
0
 
LVL 1

Author Comment

by:Trooper80
ID: 12045327
I already tried this and it does not work
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 12045354
Please post your manifest
0
 
LVL 1

Author Comment

by:Trooper80
ID: 12045378
Next time I will be less stupid not to type javollo instead of javollotest and having my program compiling and not busting ya nuts with my stupid questions
Thank you guys
I am sorry for the petty points...that's all I got
0
 
LVL 1

Author Comment

by:Trooper80
ID: 12045682
Again the stupid jar file does not work
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 12045861
But you've just accepted an answer to this question ..?
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
This video teaches viewers about errors in exception handling.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Suggested Courses
Course of the Month12 days, 7 hours left to enroll

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question