#1287 JarDist accessing fan:// resources

samjiman Tue 2 Nov 2010

Hi.

I'm having a problem with JarDist. I can build the JAR with my pod and its dependency pods okay with this script:

using build

class Build : BuildScript {

@Target { help = "Build GUIdi pod as a JAR" } Void distGUIdi() {

dist := JarDist(this)
dist.outFile = `./GUIdi.jar`.toFile.normalize
dist.podNames = Str["concurrent", "gfx", "fwt", "GUIdi"]
dist.mainMethod = "GUIdi::Main.main"
dist.run

} }

But when I try to run the created JAR with: $ java -jar GUIdi.jar

I get the following error:

sys::ArgErr: Too few arguments: 0 < instance+0..0

fan.sys.Method$MethodFunc.checkArgs (Method.java:494)   
fan.sys.Method$MethodFunc.call (Method.java:221)        
fan.sys.Method.call (Method.java:149)                   
fanjardist.Main.main (Main.java:19)                     

Since my app was GUI, I thought maybe it was a problem with missing SWT. So I added the JAR to my JRE's lib/ext. But still no luck.

I can run my pod with:

$ fan GUIdi::Main.main

So, I know that the main method I provided is correct. Any ideas would be much appreciated, thanks.

Overall I'm enjoying using Fantom. The pods is a nice system. :)

brian Tue 2 Nov 2010

Try making your main method static

samjiman Tue 2 Nov 2010

Thanks, that worked. Now I just have the problem of fan:// images not being resolved in the JAR. The error says "TODO JarStore", so I guess that functionality hasn't been completed yet.

No problem if not, I can just distributed my application slightly differently.

Thanks for your help.

brian Tue 2 Nov 2010

Promoted to ticket #1287 and assigned to brian

Thanks, that worked. Now I just have the problem of fan:// images not being resolved in the JAR. The error says "TODO JarStore", so I guess that functionality hasn't been completed yet.

Sorry about that, I will make it a ticket and ensure that gets fixed (looks like it mostly works except for the listing part

brian Tue 2 Nov 2010

Renamed from JarDist problem with GUI app to JarDist accessing fan:// resources

samjiman Tue 2 Nov 2010

Thanks. No apology needed. :)

brian Thu 11 Nov 2010

Ticket resolved in 1.0.56

I've made a number of improvements to the JarDist infrastructure.

The JarDist build target now generates a resource manifest for each pod, so that the runtime can quickly and easily implement APIs like Pod.files. As part of this process the JVM runtime now has a File implementation for ClassLoader resources (Side note of bitching: the Java API for managing files, zip entries, class resources are such a mess - all do the exact same thing with completely different APIs.)

I also added a target in buildjardist example for testSys so that we can easily run sys tests inside JarDist environment. Fixed several bugs, although there are still a couple failing tests eventually need to look at.

I also just for kicks added a target for building a simple FWT app to verify that it actually works. For some reason I couldn't get java to accept both -cp and -jar options to work simultaneous, but I was able to get a FWT app to work like this:

java -cp lib\java\ext\win32-x86_64\swt.jar;fwtTest.jar fanjardist.Main

Pretty cool actually.

cheeser Fri 12 Nov 2010

From http://download.oracle.com/javase/6/docs/technotes/tools/solaris/java.html:

When you use this option, the JAR file is the source of all user classes, and other user class path settings are ignored.

That's why -cp and -jar don't work together. -jar needs an executable jar and that jar has a Class-Path in its manifest.mf

Login or Signup to reply.