#2199 F4 won't build pod when there's a native java source file

lel4866 Thu 7 Nov 2013

I have an F4 project which has both a single fan source file and a single java source file which extends a java library (from a jar file). F4 shows no errors as far as resolving symbols is concerned, and can clearly access symbols from both the class defined by the java source file and the java library. However, when I try to run, I get the error message:

The container Fantom Native Libraries (Java) references non existing library C:\Users\lalewi\f4workspace\JavaTest2\bin\fan\lib\fan\JavaTest2.pod

and, in fact, there is nothing in JavaTest2/bin at all.

If I add the java class created by the java source file to the jar, everything works fine.

Any suggestions?

SlimerDude Thu 7 Nov 2013

Mixing Java and Fan files in the same pod is always a tad dodgy, and as I recall results in some chicken and egg scenario. (I was doing it with afFancom).

Try compiling your pod with just the Java class in it (by any means) and put it in your %FAN_HOME%\lib\fan dir with all the other pods. F4 should then happily run against this version, all the while compiling against the fan / java versions in your workspace.

You just need to remember to update the %FAN_HOME%\lib\fan pod whenever you update the Java classes.

It's been a while since I've done this, but I recall it's not an exact science. I believe the official stance is that Java sources should not be mixed with fantom sources in the pod.

brian Thu 7 Nov 2013

Basically the rules are this:

  1. If your Fantom and Java are in the same pod, then your Fantom code cannot access your Java APIs. The Java APIs can access the Fantom code. Its a matter of dependencies - the Fantom gets compiled, then the Java gets compiled next. This option is really only when writing native peer classes.
  2. If you Fantom code needs to call your Java code via FFI, then you have to pull the Java code out into a separate pod and then compile it that way. This is how we package up Java jars like lucene, etc as Fantom pods

ivan Fri 8 Nov 2013

In F4 you might also try to enable external compiler for this project (right-click project -> Properties -> Fantom -> Compiler -> Enable project specific settings + Use external compiler). After that you can also open a Console view and select Fantom Build console to check a build output:

screenshot

Login or Signup to reply.