Board index » jbuilder » Native Executable

Native Executable


2005-03-19 04:29:22 AM
jbuilder10
Hi,
I have an application that was developed using JBuilder Foundation. The app
uses Java2D and it needs a GIF to run.
It works fine in JBuilder Foundation. I can create a JAR file and run it
outside of the IDE.
Now I would like to Natively Compile it. I have it loaded into JBuilder
Developer where it also works fine in the IDE but the natively compiled
executable throws a java.lang.NullPointerException because it can't find the
GIF. I have tried putting the gif in various locations relative to the
executable.
On the Project ->Project Properties ->Resource page I have tried it with
both *.gif = Copy and Do Not Copy. The error is the same either way.
Any thoughts greatly appreciated!
mrickett
 
 

Re:Native Executable

Hi,
I have an application that was developed using JBuilder Foundation. The app
uses Java2D and it needs a GIF to run.
It works fine in JBuilder Foundation. I can create a JAR file and run it
outside of the IDE.
Now I would like to Natively Compile it. I have it loaded into JBuilder
Developer where it also works fine in the IDE but the natively compiled
executable throws a java.lang.NullPointerException because it can't find the
GIF. I have tried putting the gif in various locations relative to the
executable.
On the Project ->Project Properties ->Resource page I have tried it with
both *.gif = Copy and Do Not Copy. The error is the same either way.
Any thoughts greatly appreciated!
mrickett
 

Re:Native Executable

I am guessing that this is a static GIF file and the content of the GIF
wont change. If thats the case then add that GIF to your project (Add
files to the project option). Further load that GIF file in your code
like this
<your package name>.<your class name>.class.getResource ("your_file.GIF");
Hope this helps.
Marie Ricketts wrote:
Quote
Hi,

I have an application that was developed using JBuilder Foundation. The app
uses Java2D and it needs a GIF to run.

It works fine in JBuilder Foundation. I can create a JAR file and run it
outside of the IDE.

Now I would like to Natively Compile it. I have it loaded into JBuilder
Developer where it also works fine in the IDE but the natively compiled
executable throws a java.lang.NullPointerException because it can't find the
GIF. I have tried putting the gif in various locations relative to the
executable.

On the Project ->Project Properties ->Resource page I have tried it with
both *.gif = Copy and Do Not Copy. The error is the same either way.

Any thoughts greatly appreciated!

mrickett


 

{smallsort}

Re:Native Executable

Marie Ricketts wrote:
Quote
Hi,

I have an application that was developed using JBuilder Foundation. The app
uses Java2D and it needs a GIF to run.

It works fine in JBuilder Foundation. I can create a JAR file and run it
outside of the IDE.

Now I would like to Natively Compile it. I have it loaded into JBuilder
Developer where it also works fine in the IDE but the natively compiled
executable throws a java.lang.NullPointerException because it can't find the
GIF. I have tried putting the gif in various locations relative to the
executable.

On the Project ->Project Properties ->Resource page I have tried it with
both *.gif = Copy and Do Not Copy. The error is the same either way.

Any thoughts greatly appreciated!

mrickett


The GIF needs to be a part of your project. If it is in your source
path (along with your Java files), it should automatically be discovered.
Then, you can access the GIF file using the
getClass().getResourceAsStream("file.GIF"), provided the GIF is located
in the same directory as the class.
--
Regards,
Lori Olson [TeamB]
------------
Save yourself, and everyone else, some time and search the
newsgroups and the FAQ-O-Matic before posting your next
question.
Google Advanced Newsgroup Search
www.google.ca/advanced_group_search
Other Newsgroup Searches:
www.borland.com/newsgroups/ngsearch.html
Joi Ellis's FAQ-O-Matic:
www.visi.com/~gyles19/fom-serve/cache/1.html
 

Re:Native Executable

Marie Ricketts wrote:
Quote
I have an application that was developed using JBuilder Foundation.
The app uses Java2D and it needs a GIF to run.

It works fine in JBuilder Foundation. I can create a JAR file and run
it outside of the IDE.

Now I would like to Natively Compile it. I have it loaded into
JBuilder Developer where it also works fine in the IDE but the
natively compiled executable throws a java.lang.NullPointerException
because it can't find the GIF. I have tried putting the gif in
various locations relative to the executable.

On the Project ->Project Properties ->Resource page I have tried it
with both *.gif = Copy and Do Not Copy. The error is the same either
way.
Look at the JAR file on which the native executable is based. If the
GIF file isn't in the JAR file, then it won't be in the executable,
hence your problem.
--
Kevin Dean [TeamB]
Dolphin Data Development Ltd.
www.datadevelopment.com/
NEW WHITEPAPERS
Team Development with JBuilder and Borland Enterprise Server
Securing Borland Enterprise Server
www.datadevelopment.com/papers/index.html
Please see Borland's newsgroup guidelines at
info.borland.com/newsgroups/guide.html
 

Re:Native Executable

I have tried putting the gif everywhere and making it part of the project. I
still get:
java.lang.NullPointerException
at java2d.Intro$Surface.getImage(Intro.java:126)
at java2d.Intro$Surface.<init>(Intro.java:114)
at java2d.Intro.<init>(Intro.java:32)
at java2d.Intro.main(Intro.java:74)
public Image getImage(String name, Component cmp) {
Image img = null;
MediaTracker tracker = new MediaTracker(cmp);
URLClassLoader urlLoader =
(URLClassLoader)cmp.getClass().getClassLoader();
t ry {
getClass().getResourceAsStream("wh_logo.gif");
if ( urlLoader.findResource(name) != null) { <= this is the line
that this throwing the exception
URL fileLoc = urlLoader.findResource(name);
img = cmp.getToolkit().createImage(fileLoc);
} else {
p.l("urlLoader.findResource = null");
}
} catch (java.lang.NullPointerException npex) {
npex.printStackTrace();
System.exit(0);
}
Thanks for your help!
Marie
"Lori M Olson [TeamB]" < XXXX@XXXXX.COM >wrote in message
Quote
Marie Ricketts wrote:

>Hi,
>
>I have an application that was developed using JBuilder Foundation. The
>app
>uses Java2D and it needs a GIF to run.
>
>It works fine in JBuilder Foundation. I can create a JAR file and run it
>outside of the IDE.
>
>Now I would like to Natively Compile it. I have it loaded into JBuilder
>Developer where it also works fine in the IDE but the natively compiled
>executable throws a java.lang.NullPointerException because it can't find
>the
>GIF. I have tried putting the gif in various locations relative to the
>executable.
>
>On the Project ->Project Properties ->Resource page I have tried it
>with
>both *.gif = Copy and Do Not Copy. The error is the same either way.
>
>Any thoughts greatly appreciated!
>
>mrickett
>
>

The GIF needs to be a part of your project. If it is in your source path
(along with your Java files), it should automatically be discovered.

Then, you can access the GIF file using the
getClass().getResourceAsStream("file.GIF"), provided the GIF is located in
the same directory as the class.

--

Regards,

Lori Olson [TeamB]

------------

Save yourself, and everyone else, some time and search the
newsgroups and the FAQ-O-Matic before posting your next
question.

Google Advanced Newsgroup Search
www.google.ca/advanced_group_search
Other Newsgroup Searches:
www.borland.com/newsgroups/ngsearch.html
Joi Ellis's FAQ-O-Matic:
www.visi.com/~gyles19/fom-serve/cache/1.html