Solved

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

Posted on 2004-09-13
21
191 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
  • 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
 
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
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…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…

762 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now