I've been able to add java source for native classes and packages that as a pod. I've also been able to package a pod as a jar file for use in java. Is there a way to package jar files into pods?
For example, if a pod relies on java library x, I can put x.jar in Fantom's /lib/java/ext directory and the classes in x.jar can be loaded. Is there a way to package a specific version x.jar directly into a pod?
SlimerDudeSun 12 Feb 2012
You're essentially asking for an auto Java->Fantom converter, so I would say no, there isn't.
The differences between the two languages (and user preference on coding style) makes this a huge challenge. The JavaFFI does a fantastic job of bridging the two, so if the extra Java import statements are too much hassle I think you'll just have to write your own wrapper Pod by hand.
booleanmanSun 12 Feb 2012
I'm not looking for a way to get rid of the import statements, what I'm asking is if it's possible for pods to load java classes from jar files that are packed with the pod as opposed to installed in the system class path or in /lib/java/ext.
For example, if you create a pod that has a java source file called "Foo.java", you get the following structure as a pod:
Then the fantom classes in the pod can load fan.mypod.Foo with a using statement. My question is if it's possible to package jar files in the pod directly so that fantom classes that require java classes will have the classes available in the same pod package instead of requiring that dependencies are installed in other directories?
I'm not trying to get around using statements, I'm trying to guarantee that specific jar libraries would be shipped as part of pod.
Is that possible?
brianSun 12 Feb 2012
If you package your Java classfiles in the pod zip file, then they will be available for that pod. However, they are not "public" to other pods. For example:
podA contains java.foo.Bar.classfile
podB depends on podA
The java.foo.Bar class is available internal scope for use by podA, but will not be visible to podB.
Take a look at topic 1736 for some of my thoughts on plan forward.
booleanmanSun 12 Feb 2012
Thanks for the heads up Brian. Wrapping up jar dependencies as pods is essentially what I was asking about. It's good to know this is on the radar.
booleanman Sun 12 Feb 2012
I've been able to add java source for native classes and packages that as a pod. I've also been able to package a pod as a jar file for use in java. Is there a way to package jar files into pods?
For example, if a pod relies on java library x, I can put x.jar in Fantom's /lib/java/ext directory and the classes in x.jar can be loaded. Is there a way to package a specific version x.jar directly into a pod?
SlimerDude Sun 12 Feb 2012
You're essentially asking for an auto Java->Fantom converter, so I would say no, there isn't.
The differences between the two languages (and user preference on coding style) makes this a huge challenge. The JavaFFI does a fantastic job of bridging the two, so if the extra Java import statements are too much hassle I think you'll just have to write your own wrapper Pod by hand.
booleanman Sun 12 Feb 2012
I'm not looking for a way to get rid of the import statements, what I'm asking is if it's possible for pods to load java classes from jar files that are packed with the pod as opposed to installed in the system class path or in /lib/java/ext.
For example, if you create a pod that has a java source file called "Foo.java", you get the following structure as a pod:
Then the fantom classes in the pod can load fan.mypod.Foo with a using statement. My question is if it's possible to package jar files in the pod directly so that fantom classes that require java classes will have the classes available in the same pod package instead of requiring that dependencies are installed in other directories?
Something along the lines of:
I'm not trying to get around using statements, I'm trying to guarantee that specific jar libraries would be shipped as part of pod.
Is that possible?
brian Sun 12 Feb 2012
If you package your Java classfiles in the pod zip file, then they will be available for that pod. However, they are not "public" to other pods. For example:
The
java.foo.Bar
class is available internal scope for use bypodA
, but will not be visible topodB
.Take a look at topic 1736 for some of my thoughts on plan forward.
booleanman Sun 12 Feb 2012
Thanks for the heads up Brian. Wrapping up jar dependencies as pods is essentially what I was asking about. It's good to know this is on the radar.