Solved

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

Posted on 2004-09-13
21
201 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
The Ultimate Checklist to Optimize Your Website

Websites are getting bigger and complicated by the day. Video, images, custom fonts are all great for showcasing your product/service. But the price to pay in terms of reduced page load times and ultimately, decreased sales, can lead to some difficult decisions about what to cut.

 
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 20 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

Transaction Monitoring Vs. Real User Monitoring

Synthetic Transaction Monitoring Vs. Real User Monitoring: When To Use Each Approach? In this article, we will discuss two major monitoring approaches: Synthetic Transaction and Real User Monitoring.

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…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …

719 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