#2646 Including JAR into Pod for SkySpark v3

Paul Fri 29 Sep

I'm attempting to build a POD which includes a JAR file, but it kicks back the following error

AwsLib.fan(14,1): Java package 'com.amazonaws.auth' not found
AwsLib.fan(29,1): Java package 'com.mycompany.services.ses' not found

My build.fan file contains the following

srcDirs = [`fan/`, `fan/ui`],
resDirs = [`locale/`, `lib/`, `lib/ext/mycompany.jar`]

The mycompany.jar file contains everything from com.amazonaws.* and com.mycompany.* I've tried putting the Java source into a java directory, and updated the build.fan file accordingly, but I still received the same error.

My directory structure is

build.fan
fan/
  ui/
    AwsApp.fan
  AwsExt.fan
  AwsLib.fan
lib/ext/
  mycompany.jar

I'm running Fantom version 1.0.69.12 and SkySpark version 3.0.12.

brian Fri 29 Sep

You cannot mix Java code and Fantom Java FFI calls in the same pod. You need to instead to create one Fantom pod that wraps the jar, and then have your Fantom code depend on that pod.

For example in SkySpark the sedona.pod just wraps sedona.jar with a build script that looks like this:

resDirs = [`sedona.jar`]

Then sedonaExt depends on it and imports Java types using FFI:

using [java]sedona.sox

Or put another way - Java FFI cannot resolve Java types within your own pod

Paul Wed 4 Oct

That worked. Thank you.

Login or Signup to reply.