Solved

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

Posted on 2004-09-13
21
193 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
ScreenConnect 6.0 Free Trial

Discover new time-saving features in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

 
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

ScreenConnect 6.0 Free Trial

Explore all the enhancements in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Java SE 8u111  Lot of stuff broke 11 69
Spring Framework HTTPSession management 1 35
MySqlDump not dumping triggers 1 31
Java string replace 11 47
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
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 how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

773 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