You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@pivot.apache.org by Bill van Melle <bi...@gmail.com> on 2011/01/12 23:47:28 UTC

Exporting my app to a jar file

This seems like it must be a pretty elementary question, but what do I need
to do to make a runnable jar file out of my app?  I'm using Eclipse, where
my app runs fine.  I tried doing Export | Runnable JAR file, but when I run
it, it dies while parsing the top-level bxml file, where it fails to find a
file that's included from it.  Here's what Java reports:

An error occurred at line number 21 in file
com/fxpal/myunity/DashboardWindow.bxml:
java.net.MalformedURLException: Could not open InputStream for URL
'rsrc:Dashboard.bxml'
at
org.eclipse.jdt.internal.jarinjarloader.RsrcURLConnection.getInputStream(RsrcURLConnection.java:46)
at java.net.URL.openStream(Unknown Source)
at
org.apache.pivot.beans.BXMLSerializer.processStartElement(BXMLSerializer.java:881)
at org.apache.pivot.beans.BXMLSerializer.readObject(BXMLSerializer.java:435)
at org.apache.pivot.beans.BXMLSerializer.readObject(BXMLSerializer.java:614)
at org.apache.pivot.beans.BXMLSerializer.readObject(BXMLSerializer.java:568)
at org.apache.pivot.beans.BXMLSerializer.readObject(BXMLSerializer.java:534)
at com.fxpal.myunity.DashboardWindow.create(DashboardWindow.java:28)
at com.fxpal.myunity.Program.startup(Program.java:27)
at
org.apache.pivot.wtk.DesktopApplicationContext$2.run(DesktopApplicationContext.java:594)
at
org.apache.pivot.wtk.ApplicationContext$QueuedCallback.run(ApplicationContext.java:1474)
        ...

The file it's parsing at the time looks like

<my:DashboardWindow
    xmlns:bxml="http://pivot.apache.org/bxml"
    xmlns:my="com.fxpal.myunity"
    xmlns="org.apache.pivot.wtk">

 ... some containers inside other containers ...

       <bxml:include bxml:id="dashboard" src="Dashboard.bxml" />

 ... etc ...

You've said that include directives with non-absolute paths are interpreted
relative to the file being parsed.  Dashboard.bxml is indeed in the jar file
and in the same directory as DashboardWindow.bxml.  The
method DashboardWindow.create looks like this:

    public static Window create() throws IOException, SerializationException
{ BXMLSerializer bxmlSerializer = new BXMLSerializer(); return
(DashboardWindow)bxmlSerializer.readObject(DashboardWindow.class,
"DashboardWindow.bxml"); }

What am I missing?

Re: Exporting my app to a jar file

Posted by Bill van Melle <bi...@gmail.com>.
Thanks, that works!  I had the other option checked ("Package required
libraries into generated JAR").  It's not at all clear to me why one would
work and the other not.  I'm guessing it's because things aren't indirected
thru the eclipse JarRsrcLoader.

Greg, if you're assembling a Pivot tips and tricks document anywhere, you
might want to put this in there.



On Wed, Jan 12, 2011 at 3:54 PM, Martin Jimenez-Salazar <
excalibur506@gmail.com> wrote:

> Friend, inside the eclipse go top
> File/Export/Java/Runnable Jar file
>
> Then, select the launch configuration you use for running the app from the
> ide,
> the export destination is the name of the executable something like
> (~/my_app.jar in linux or c:\some_dir\my_app.jar)
> .
> The most important part is in the "library handling:" section, You MUST
> choose "Extract required libraries into generated JAR".
> that option will make Eclipse to create one big jar, including your jars
> plus the pivot's jar.
>
> hope this will help
>
> Martin
>

Re: Exporting my app to a jar file

Posted by Martin Jimenez-Salazar <ex...@gmail.com>.
Friend, inside the eclipse go top
File/Export/Java/Runnable Jar file

Then, select the launch configuration you use for running the app from the
ide,
the export destination is the name of the executable something like
(~/my_app.jar in linux or c:\some_dir\my_app.jar)
.
The most important part is in the "library handling:" section, You MUST
choose "Extract required libraries into generated JAR".
that option will make Eclipse to create one big jar, including your jars
plus the pivot's jar.

hope this will help

Martin


2011/1/12 Greg Brown <gk...@verizon.net>

> > This seems like it must be a pretty elementary question, but what do I
> need to do to make a runnable jar file out of my app?  I'm using Eclipse,
> where my
> > ...
> > What am I missing?
>
> Not sure - I usually use Ant to generate JAR files. Never tried it from
> Eclipse - maybe someone else can offer some insight?
>
>
>

Re: Exporting my app to a jar file

Posted by Greg Brown <gk...@verizon.net>.
> This seems like it must be a pretty elementary question, but what do I need to do to make a runnable jar file out of my app?  I'm using Eclipse, where my
> ...
> What am I missing?

Not sure - I usually use Ant to generate JAR files. Never tried it from Eclipse - maybe someone else can offer some insight?



Re: Exporting my app to a jar file

Posted by Luiz Gustavo <lu...@gmail.com>.
HI!

What is that 'rsrc: in your URL (in the exception)?

I generate jar files from eclipse normally.


Cheers,
Luiz Gustavo


2011/1/12 Bill van Melle <bi...@gmail.com>

> This seems like it must be a pretty elementary question, but what do I need
> to do to make a runnable jar file out of my app?  I'm using Eclipse, where
> my app runs fine.  I tried doing Export | Runnable JAR file, but when I run
> it, it dies while parsing the top-level bxml file, where it fails to find a
> file that's included from it.  Here's what Java reports:
>
> An error occurred at line number 21 in file
> com/fxpal/myunity/DashboardWindow.bxml:
> java.net.MalformedURLException: Could not open InputStream for URL
> 'rsrc:Dashboard.bxml'
>  at
> org.eclipse.jdt.internal.jarinjarloader.RsrcURLConnection.getInputStream(RsrcURLConnection.java:46)
> at java.net.URL.openStream(Unknown Source)
>  at
> org.apache.pivot.beans.BXMLSerializer.processStartElement(BXMLSerializer.java:881)
> at
> org.apache.pivot.beans.BXMLSerializer.readObject(BXMLSerializer.java:435)
>  at
> org.apache.pivot.beans.BXMLSerializer.readObject(BXMLSerializer.java:614)
> at
> org.apache.pivot.beans.BXMLSerializer.readObject(BXMLSerializer.java:568)
>  at
> org.apache.pivot.beans.BXMLSerializer.readObject(BXMLSerializer.java:534)
> at com.fxpal.myunity.DashboardWindow.create(DashboardWindow.java:28)
>  at com.fxpal.myunity.Program.startup(Program.java:27)
> at
> org.apache.pivot.wtk.DesktopApplicationContext$2.run(DesktopApplicationContext.java:594)
>  at
> org.apache.pivot.wtk.ApplicationContext$QueuedCallback.run(ApplicationContext.java:1474)
>         ...
>
> The file it's parsing at the time looks like
>
> <my:DashboardWindow
>     xmlns:bxml="http://pivot.apache.org/bxml"
>     xmlns:my="com.fxpal.myunity"
>     xmlns="org.apache.pivot.wtk">
>
>  ... some containers inside other containers ...
>
>        <bxml:include bxml:id="dashboard" src="Dashboard.bxml" />
>
>  ... etc ...
>
> You've said that include directives with non-absolute paths are interpreted
> relative to the file being parsed.  Dashboard.bxml is indeed in the jar file
> and in the same directory as DashboardWindow.bxml.  The
> method DashboardWindow.create looks like this:
>
>     public static Window create() throws IOException,
> SerializationException { BXMLSerializer bxmlSerializer = new
> BXMLSerializer(); return
> (DashboardWindow)bxmlSerializer.readObject(DashboardWindow.class,
> "DashboardWindow.bxml"); }
>
> What am I missing?
>
>