Solved

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

Posted on 2004-09-13
21
196 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Opening PDF on button click and fill new document 2 53
web application structure 18 111
DTD and JAVA versions 1 28
Tomcat 9 + java 8 error while trying to deploy a war file 2 692
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…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…

740 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