Looking to get started with Fantom and need to be able to pull in some existing java classes. I ran through the example here,http://www.alienfactory.co.uk/articles/intro-to-f4. for setting up the F4 IDE to test some of the pure Fantom examples and that worked no problem. Tried to bring in the Java examples and run into a couple of problems.
When I try to run any of the examples I get an "Invalid Uri scheme for local file" error. Based on past experience with this kind of thing, i'm going to assume this is because there is a space in my windows user name and the compiler doesn't know how to handle that.
The hello.fan file shows one error: Description Resource Path Location Type Ambiguous type: sys::Void, [java]java.lang::Void hello.fan /Examples/fan/java /Examples/fan/java/hello.fan Fantom Problem
There seems to be no documentation anywhere that I can find on resolving this type of issue though so i'm kind of stuck on getting started if I want to bring in any existing java code into a fantom project.
SlimerDudeMon 15 Aug 2016
Hi jhughes,
I think this just requires more understanding of file URIs on Windows...
I doubt Invalid Uri scheme for local file has anything to do with spaces, instead look for a file URI that has an absolute path including a drive:
`C:/my/absolute/path.txt`
Note that C is interpreted as a scheme like http but is not valid for file systems. Instead ensure the URI starts with a / so Fantom knows that C: is part of the path:
`/C:/my/absolute/path.txt`
Or to be extra safe and sure, make sure it has the file scheme:
`file:/C:/my/absolute/path.txt`
The hello.fan example needs updating. The compiler is getting confused between Java's Void and Fantom's Void. Adding an extra using statement to distinguish between the two should help:
using [java] java.lang
using [java] java.lang::Void as JVoid
**
** Hello world using System.out.println
**
class HelloWorld
{
Void main()
{
System.out.println("Java FFI hello world")
}
}
Hope this helps,
Steve.
jhughesMon 15 Aug 2016
Where would I go about changing the URI in this case? All I've done at this point is start a project in F4 and bring in the example files. Not really sure where to go in the IDE to modify how it's resolving the file URI or if that's even an IDE issue.
The extra using line has resolved that error, thanks.
SlimerDudeMon 15 Aug 2016
Where would I go about changing the URI in this case?
I don't know. Without a stacktrace, or knowing which example you're running, or even a complete error message, I can't really say what might be going wrong.
jhughesMon 15 Aug 2016
This is concerning the hello.fan example for using java.
I've attempted to get this resolved referencing the topic about getting the examples running (http://fantom.org/forum/topic/2334). Imported the example F4 project and put the hello.fan java example into it and get the same stack trace but with a slightly different error. The exact same stack trace actually exists in all the example files for that project for me but still manage to run the code after it.
Thanks, if the error is from PathEnv and happens for all Fantom programs then it strongly suggests that you have a bad FAN_PATH_ENV environment variable set up.
Assuming you've not set anything up in F4, can you report what the following says when typed into a standard command prompt:
C:\> set fan
For comparison, mine says:
C:\>set fan
FAN_ENV=
FAN_ENV_PATH=C:\Repositories-Fantom\workDir
FAN_HOME=C:\Apps\fantom-1.0.69
Note that having a FAN_ENV_PATH environment variable is completely optional, and should only exist if you wish to make use of PathEnv or a customised FPM Env.
If you do have an FAN_ENV_PATH (and / or a FAN_ENV) environment variable then I would suggest removing them until the basic examples are working.
jhughesMon 15 Aug 2016
C:\Users\Jonathan Hughes>set fan Environment variable fan not defined
Noting appears to be setup concerning those variables so I don't have anything to remove.
SlimerDudeTue 16 Aug 2016
Okay, I see partly what's going on.
You're using F4 v1.0.2 - this older version sets up PATH_ENV_PATH for you when launching programs.
Note that this error should not prevent your programs from running. If Fantom can't initialise PathEnv then I believe it defaults to using BootEnv and carries on. The only time you would need PathEnv is when you have multiple related projects open in F4 - which I assume you don't right now.
I tried to deduce (by matching up your stack trace with different Fantom versions), that you've added an interpreter to F4 for Fantom 1.0.69 - is that correct?
If so, I cannot reproduce your error. I downloaded a clean install of F4 1.0.2 & Fantom 1.0.69 and created a new project, in a path with spaces (just to make sure!) and ran the following, error free:
Does your project look much different?
In any case, I would strongly recommend downloading a preview of F4 v1.1.0 from the nightly builds, for as mentioned in other threads, it solves a lot of problems.
Note the new version uses a bespoke F4Env as its Fantom environment and notPathEnv so it may fix your URI parsing issue. If the problem does re-manifest itself, then I can always patch F4Env.
jhughesTue 16 Aug 2016
I'll start by letting you know that after installing the nightly build and opening in the same work space, so essentially nothing else changed, code runs without errors.
Thanks for pointing me to that page.
Now to answer the questions about this issue:
There is only one download link on the F4 website you are directed to from the IDE link in the docs section of fantom (http://www.xored.com/products/f4/) and that's what downloaded when I set this all up yesterday. Side note, the about in that version still shows 1.0.1 but apparently it's a really old version so i'm not going to worry about that.
Not sure how you or where the nightly builds site was discovered if the main F4 website doesn't even host the latest or seemingly a link to that site anywhere on the page but that's a big hindrance of this IDE has this many gotchyas just to set up hello world.
You are correct in the pairing, F4 and Fantom 1.0.69. The picture you posted is not visible so I can't tell you if they look different.
Did you test with the same missing environment variables that I had or were they setup on your machine? Just curious why it would work on your system with a clean install when that's exactly what I did yesterday when I started this.
Hope somebody starts to maintain that download site on the main F4 page or the fantom docs can get updated to point to the nightly builds since whatever's on that site right now is problematic at best.
jhughesTue 16 Aug 2016
Now that I got hello.fan to run with java in the IDE, I copied the jar I really wanted to start using within fantom to fantom/lib/java folder and it shows up in the Fantom Native Libraries in the IDE. I created a new fantom class to inherit one of the classes from the jar but when I attempt to import I get: "No FFI Bridge for 'jarName'.
Are there more steps that need to be taken in the IDE to allow jars to be recognized?
jhughesTue 16 Aug 2016
Disregard the last comment. I figured out what I did wrong.
jhughes Mon 15 Aug 2016
Looking to get started with Fantom and need to be able to pull in some existing java classes. I ran through the example here,http://www.alienfactory.co.uk/articles/intro-to-f4. for setting up the F4 IDE to test some of the pure Fantom examples and that worked no problem. Tried to bring in the Java examples and run into a couple of problems.
There seems to be no documentation anywhere that I can find on resolving this type of issue though so i'm kind of stuck on getting started if I want to bring in any existing java code into a fantom project.
SlimerDude Mon 15 Aug 2016
Hi
jhughes
,I doubt
Invalid Uri scheme for local file
has anything to do with spaces, instead look for a file URI that has an absolute path including a drive:`C:/my/absolute/path.txt`
Note that
C
is interpreted as a scheme likehttp
but is not valid for file systems. Instead ensure the URI starts with a/
so Fantom knows thatC:
is part of the path:`/C:/my/absolute/path.txt`
Or to be extra safe and sure, make sure it has the
file
scheme:`file:/C:/my/absolute/path.txt`
hello.fan
example needs updating. The compiler is getting confused between Java'sVoid
and Fantom'sVoid
. Adding an extrausing
statement to distinguish between the two should help:Hope this helps,
Steve.
jhughes Mon 15 Aug 2016
SlimerDude Mon 15 Aug 2016
I don't know. Without a stacktrace, or knowing which example you're running, or even a complete error message, I can't really say what might be going wrong.
jhughes Mon 15 Aug 2016
This is concerning the hello.fan example for using java.
[14:56:15 15-Aug-16] [err] [pathenv] Cannot parse path: C:\Users\Jonathan Hughes\f4workspace\FantomExamples\bin\fan;C:\Fantom\Examples\bin\fan
ERROR: sys::UnknownPodErr: examples
I've attempted to get this resolved referencing the topic about getting the examples running (http://fantom.org/forum/topic/2334). Imported the example F4 project and put the hello.fan java example into it and get the same stack trace but with a slightly different error. The exact same stack trace actually exists in all the example files for that project for me but still manage to run the code after it.
[14:59:32 15-Aug-16] [err] [pathenv] Cannot parse path: C:\Users\Jonathan Hughes\f4workspace\FantomExamples\bin\fan;C:\Fantom\Examples\bin\fan
ERROR: sys::UnknownTypeErr: FantomExamples::HelloWorld
SlimerDude Mon 15 Aug 2016
Thanks, if the error is from
PathEnv
and happens for all Fantom programs then it strongly suggests that you have a badFAN_PATH_ENV
environment variable set up.Assuming you've not set anything up in F4, can you report what the following says when typed into a standard command prompt:
For comparison, mine says:
Note that having a
FAN_ENV_PATH
environment variable is completely optional, and should only exist if you wish to make use of PathEnv or a customised FPM Env.If you do have an
FAN_ENV_PATH
(and / or aFAN_ENV
) environment variable then I would suggest removing them until the basic examples are working.jhughes Mon 15 Aug 2016
C:\Users\Jonathan Hughes>set fan Environment variable fan not defined
Noting appears to be setup concerning those variables so I don't have anything to remove.
SlimerDude Tue 16 Aug 2016
Okay, I see partly what's going on.
You're using F4 v1.0.2 - this older version sets up
PATH_ENV_PATH
for you when launching programs.Note that this error should not prevent your programs from running. If Fantom can't initialise
PathEnv
then I believe it defaults to usingBootEnv
and carries on. The only time you would needPathEnv
is when you have multiple related projects open in F4 - which I assume you don't right now.I tried to deduce (by matching up your stack trace with different Fantom versions), that you've added an interpreter to F4 for Fantom 1.0.69 - is that correct?
If so, I cannot reproduce your error. I downloaded a clean install of F4 1.0.2 & Fantom 1.0.69 and created a new project, in a path with spaces (just to make sure!) and ran the following, error free:
Does your project look much different?
In any case, I would strongly recommend downloading a preview of F4 v1.1.0 from the nightly builds, for as mentioned in other threads, it solves a lot of problems.
Note the new version uses a bespoke
F4Env
as its Fantom environment and notPathEnv
so it may fix your URI parsing issue. If the problem does re-manifest itself, then I can always patch F4Env.jhughes Tue 16 Aug 2016
I'll start by letting you know that after installing the nightly build and opening in the same work space, so essentially nothing else changed, code runs without errors.
Thanks for pointing me to that page.
Now to answer the questions about this issue:
There is only one download link on the F4 website you are directed to from the IDE link in the docs section of fantom (http://www.xored.com/products/f4/) and that's what downloaded when I set this all up yesterday. Side note, the about in that version still shows 1.0.1 but apparently it's a really old version so i'm not going to worry about that.
Not sure how you or where the nightly builds site was discovered if the main F4 website doesn't even host the latest or seemingly a link to that site anywhere on the page but that's a big hindrance of this IDE has this many gotchyas just to set up hello world.
You are correct in the pairing, F4 and Fantom 1.0.69. The picture you posted is not visible so I can't tell you if they look different.
Did you test with the same missing environment variables that I had or were they setup on your machine? Just curious why it would work on your system with a clean install when that's exactly what I did yesterday when I started this.
Hope somebody starts to maintain that download site on the main F4 page or the fantom docs can get updated to point to the nightly builds since whatever's on that site right now is problematic at best.
jhughes Tue 16 Aug 2016
Now that I got hello.fan to run with java in the IDE, I copied the jar I really wanted to start using within fantom to fantom/lib/java folder and it shows up in the Fantom Native Libraries in the IDE. I created a new fantom class to inherit one of the classes from the jar but when I attempt to import I get: "No FFI Bridge for
'jarName'.
Are there more steps that need to be taken in the IDE to allow jars to be recognized?
jhughes Tue 16 Aug 2016
Disregard the last comment. I figured out what I did wrong.