As I'm a newbie to Fantom and Eclipse (F4), is there anyone who could give me a step-by-step tutorial on how to make F4 project from the examples found in the Fantom distribution and to run them also?
HertzSun 24 Aug 2014
This is what worked for me.
Create a new fantom project in f4 file > new fantom project
You can name it examples or another name of your choosing
Once the project is created delete the emptyfan folder
From you system's file manager/explorer open LOCATION_TO_FANTOM/examples folder
Copy the 8 example folders. Select them all Ctr-V for windows or right click > copy
Go into f4, right click on examples project( or whatever you called it), and click paste.
Open up a .fan file from the folders and run it like normal.
If you have any other questions you can ask.
rasaSun 24 Aug 2014
No, it didn't work. You must be wrong somewhere.
HertzSun 24 Aug 2014
Hmm? Where is the problem occurring? Also what computer platform are you running on?
rasaMon 25 Aug 2014
I'm using Win7 64bit. I'd tried to run sys:stmts.fan and here is what I got:
Are you running it from the cmd line? Does the directory C:\Users\rasa\f4workspace\Fantom v1.0.66 Examples\bin\fan exist?
Are you purposely setting / using a PathEnv? If not, try un-setting the environment variable and re-running the example.
C:\> set FAN_ENV=
C:\> fan stmts.fan
rasaMon 25 Aug 2014
@Hertz told me to delete fan folder that were made by F4 New project wizard. Now I made new fan folder and moved all examples into it. Next, I'd tried to navigate to that folder manually and ran this example:
But note that I'm inexperienced Eclipse user, so maybe I'm doing something wrong in F4. 1) open project (all examples are in fan folder) 2) open lists.fan in editor 3) click on "Run As..." 4) a dialog "Run As" pops up giving me the options: "Fantom class" and "Fantom testing" 5) I choose "Fantom class" 6) erros show up!
I still don't know how to run lists.fan as a script inside F4.
rasaTue 26 Aug 2014
Is there anybody who uses F4 under Win7? I've managed to run examples only using NetBeans IDE but failed with F4 and Camembert. I couldn't even start Camembert. Also tried Fantom plugin for IntelliJ IDEA, but it doesn't work for IDEA v13. Authors have stopped working on it since IDEA v9. Source code is unavailable.
Is there someone who is in the mood to run Fantom examples in Win7 using F4 IDE and test if they could be ran without problems?
brianTue 26 Aug 2014
@rasa,
Based on the one exception you posted, make sure you are using proper URIs and not Window's file paths if you have any configuration files. Everything in Fantom uses URIs for the most part. To check a Window's path as URI in fansh:
File.os("windows path")
rasaTue 26 Aug 2014
fansh just prints: windows path
p.s. I can start examples in NetBeans because there is an option "Run as a script" if I remember well. There is no such option in F4 so I can't solve the problem.
SlimerDudeTue 26 Aug 2014
Is there anybody who uses F4 under Win7?
Yep - me! F4 under Win7 64 bit to be exact.
in NetBeans there is "Run as a script" There is no such option in F4.
Right click, "Run As... Fantom Class" runs the class as a Fantom script. You are doing the right thing.
(Note that windows path has been substituted with the, um, Windows path!)
Anyway, I strongly suspect that you have a project mis-configured in F4.
F4 does not really deal with individual Fantom files, but rather Fantom projects so we need to ensure the project is setup correctly before we can run the classes / scripts.
In the project directory you will find 3 F4 text files, .project, .classpath and .buildpath (F4 hides these because they start with a dot, so use a normal Windows explorer / notepad to open them). If you post the contents of those 3 files AND build.fan I'll have a look and see what I can spot.
Oh, and close ALL projects except the one with the examples.
rasaTue 26 Aug 2014
Oh, I taught that "windows path" was some key. Sorry.
Note that I had to change backslash into forwardslash in order to execute File.os Otherwise fansh argued with: ERROR(17): Invalid escape sequence
Note that I've made a new project, so now the root folder is named FantomExamples. Inside that project I have only one folder named "fan" and 3 config files. 4th file build.fan seems to be aded uppon compiling, but I'm not sure about that. I have no idea why F4 reports that it cannot parse the path "C:\Users\rasa\f4workspace\FantomExamples\bin\fan" when the folder "bin" doesn't even exists?
When I mentioned F4 builds Fantom projects, more specifically I mean it builds Fantom pods. One F4 project builds one Fantom pod.
All the example files in the different directories can not (without modification) be built into a single pod. Mainly because to build a Fantom pod, all the class names in all the .fan files have to be different and all the .fan files need to have different names.
I imagine you have a couple of red crosses in your project, which looks like:
In F4, when you run a class as a script, it runs it from the built .pod. If you have errors / red crosses in your project (or problems in the Problems View) then the .pod is not being built and you will not be able to run classes without error.
So we're going change the FantomExamples project to just contain the files from fan/sys/ directory. Delete the other directories and copy the contents of fan/sys/ into fan/ and delete fan/sys/. Refresh the project in F4 (Right-click on the project -> Refresh (F5)) and it should look like this:
Note that reflection.fan needs fwt added as dependency to build.fan. Afterwards, your build.fan should look like:
using build
class Build : build::BuildPod
{
new make()
{
podName = "FantomExamples"
summary = ""
srcDirs = [`fan/`]
depends = ["sys 1.0", "fwt 1.0"]
}
}
You project should now have no red crosses! And the Problems View should be clear. ( Window -> Show View -> Problems if you can't see the Problems View).
Now you should be able to right click on any .fan file, in either the Fantom Explorer View or the Editor, and Run As... -> Fantom Class.
If you're still having trouble, I've zipped up a working F4 project for the sys examples here: fantomExamples.zip
More Info on .pods
As mentioned earlier, F4 runs the class from the .pod file. By default the .pod file is build to:
<project-dir>/bin/fan/lib/fan/<project-name>.pod
So you can look for it there. If you clean the project (Project -> clean...) then the .pod file should get rebuilt. So if you delete the .pod file and clean the project, you should see it getting rebuilt.
If the pod does not get re-built, you still have an error in your F4 project.
I've never tried to run the Fantom examples from within F4 before, and um, yes, it does not appear to be not straight forward.
@Brain n @Andy: What do you think about modifying the examples/ dir so that it builds an examples.pod?
Still have each file executable as a script, but maybe tidy up the class and file names so that they're all different and alter the build.fan so it has the correct dependencies and compiles all the examples into one pod?
SlimerDudeTue 26 Aug 2014
I had to change backslash into forwardslash in order to execute
Oh yeah... backslashes in URIs need to be escaped with a backslash:
(But if the project / pod wasn't being built then that would have been a red-herring anyway.)
rasaWed 27 Aug 2014
OK, I understand, but I don't want to make many small projects as it is alredy possible to run all scripts inside NetBeans without slicing them into independable pods. So, i tried refactoring. I had to rename only 3 files:
Don't know what is all about. Commented whole main method in this class to make F4 and its Problems view happy. Then I started other examples and everything was OK.
Here I have some questions and advices:
How can I resolve mentioned problem?
Is there any way I can switch off annoying "Run As" window in F4?
Make examples project for F4 as SlimerDude suggested for there is a config file for NetBeans already.
How do i know what version numbers to put into pod dependencies? It seems that compiler will notify me what versions do I need for compiling. Am I right? And then, if I'm right, how and where do I search for the right version?
SlimerDudeWed 27 Aug 2014
So, i tried refactoring.
Well done! I didn't want to give you any more extra steps!
In hellojava.fan replace the using line with
using [java] java.lang::System
This imports / uses only the Java System class which prevents a conflict between the 2 Void classes. (Fantom and Java's.) The conflict is probably an F4 bug.
Don't know what you mean.
...
See the Depends class for version syntax. sys 1.0 actually means sys 1.0.* so it happily matches sys 1.0.66; the current Fantom version.
It seems that compiler will notify me what versions do I need for compiling.
No, it uses whatever you put in build.fan.
Note that you can only have ONE version of a pod in any given Fantom environment; which is hinted at by the fact .pod files don't have version numbers.
rasaWed 27 Aug 2014
that solved the problem
every time I click "Run As" in F4, a Dialog "Run As" appears forcing me to choose, i.e. click on, one of two options: "Fantom Class" and "Fantom Testing". OK button is disabled till I choose something. There is no default selection also. Popping of this window every time i want to run some script is really annoying. What is the way to suppress its appearance?
Note that you can only have ONE version of a pod in any given Fantom environment; which is hinted at by the fact .pod files don't have version numbers.
Why then one have to put version numbers in dependencies list?
What is the best strategy for installing pods? To put its latest versions or what? What if the functionality of some pod changes between versions? I really don't understand how only one pod can be enough for full functionality?
p.s. How do I attach an image to the post?
SlimerDudeWed 27 Aug 2014
Click the down chevron next to the Run As button:
And that brings up a list of recent Run Configurations. Whatever you ran last should be towards the top of the list.
Why then one have to put version numbers in dependencies list?
To make sure you're using the correct version for the project!
You can't. You have to upload your image to somewhere on the web and link to it using the image syntax.
rasaWed 27 Aug 2014
And, that's it? I always have to click on down chevron and then choose run configuration. It is impossible to set default run config or use keyboard shortcut?
It is a very highly capable IDE, but when first learning it the things that you want to do with a simple project are more complex than you'd expect.
F4 still looks very good once it is properly configured - though because its developers seem to have stopped I do worry whether this will remain.
The things that are awkward for me: (1) standard compile and launch needing two clicks - the above key shortcut looks the best workaround, if it works (seems not to on my Mac). And anyway the twi clicks are not too bad.
(2) build & run (or build and debug) will run the last working version on compiler failure. Of course what you WANT is for the process to stop on compile failure.
This one is really annoying. The solution I've found is a bit messy but works. F4 "build" will run the build script. You can alter this by overriding the called method of Build so that compile failure will exit and not run the code.
(3) as the OP said, what is needed is a step by step bomb-proof tutorial for how to get started with F4 and Fantom so that those new to the language can get started on 64 bit win7 or (yuk) win8 without 3 hours checking configurations and experimenting. It is not simple because you have choice of 32/64 bit Java (and different versions) and 32/64 bit F4.
This tutorial needs to include stuff about how to set up your Fantom project and source file(s), how to alter build.fan to decent "compile and run only if compile succeeds" behaviour, etc. All if possible in a shrink-wrapped form.
SlimerDudeSun 31 Aug 2014
its developers seem to have stopped
Ivan still does some tweaks now and then. The source is available on GitHub and can be built with maven.
Editors in general are a very personal thing... here is my take on your points:
Launching is not an issue for me. Either I'm running a BedSheet app which re-deploys itself when pods change or I'm re-running unit tests which is just a button click on the Script Unit Test view.
Again, not really an issue for me. A quick glimpse at the Problems View tells me if I have errors, and I don't run anything if errors exist.
Ivan did commit a fix for this, but in my opinion it (unfortunately) causes more issues than it fixes.
I think your idea of altering build.fan is probably the best for now.
I've managed to run examples in F4 successfully, but that was at my work site comp. Now I tried to do the same at home and failed with an already well known error:
I taught that I had resolved that error by doing all the steps above but it seems that I solved it accidentally. By comparing project and F4 configurations at home and at the work place I have discovered that all configs are identical. But then I compared project folders in file manager (not visible in project tree) and discovered that I really have the bin folder in my work comp and that there is no such folder in home comp. Here is how this folder looks like:
bin\fan\lib\fan\FantomExamples.pod
I have copied this folder into the project folder of my home comp and ran the examples without errors. The problem is that I'm not aware how I have created this folder structure at work comp? It's created by F4 but I don't know how and when that happened?
SlimerDudeThu 4 Sep 2014
From my observations, the directory structure (and pod) are created by F4 when the project successfully compiles for the first time. If your project never compiled then the directory structure (and pod) would not be created.
rasaFri 5 Sep 2014
Not sure about that. There were no problems or warnings during compilation but project pod was not created.
rasa Sun 24 Aug 2014
As I'm a newbie to Fantom and Eclipse (F4), is there anyone who could give me a step-by-step tutorial on how to make F4 project from the examples found in the Fantom distribution and to run them also?
Hertz Sun 24 Aug 2014
This is what worked for me.
If you have any other questions you can ask.
rasa Sun 24 Aug 2014
No, it didn't work. You must be wrong somewhere.
Hertz Sun 24 Aug 2014
Hmm? Where is the problem occurring? Also what computer platform are you running on?
rasa Mon 25 Aug 2014
I'm using Win7 64bit. I'd tried to run sys:stmts.fan and here is what I got:
SlimerDude Mon 25 Aug 2014
Are you running it from the cmd line? Does the directory
C:\Users\rasa\f4workspace\Fantom v1.0.66 Examples\bin\fan
exist?Are you purposely setting / using a
PathEnv
? If not, try un-setting the environment variable and re-running the example.rasa Mon 25 Aug 2014
@Hertz told me to delete fan folder that were made by F4 New project wizard. Now I made new fan folder and moved all examples into it. Next, I'd tried to navigate to that folder manually and ran this example:
It worked. It works for other examples too.
But note that I'm inexperienced Eclipse user, so maybe I'm doing something wrong in F4. 1) open project (all examples are in fan folder) 2) open lists.fan in editor 3) click on "Run As..." 4) a dialog "Run As" pops up giving me the options: "Fantom class" and "Fantom testing" 5) I choose "Fantom class" 6) erros show up!
I still don't know how to run lists.fan as a script inside F4.
rasa Tue 26 Aug 2014
Is there anybody who uses F4 under Win7? I've managed to run examples only using NetBeans IDE but failed with F4 and Camembert. I couldn't even start Camembert. Also tried Fantom plugin for IntelliJ IDEA, but it doesn't work for IDEA v13. Authors have stopped working on it since IDEA v9. Source code is unavailable.
Is there someone who is in the mood to run Fantom examples in Win7 using F4 IDE and test if they could be ran without problems?
brian Tue 26 Aug 2014
@rasa,
Based on the one exception you posted, make sure you are using proper URIs and not Window's file paths if you have any configuration files. Everything in Fantom uses URIs for the most part. To check a Window's path as URI in fansh:
rasa Tue 26 Aug 2014
fansh just prints: windows path
p.s. I can start examples in NetBeans because there is an option "Run as a script" if I remember well. There is no such option in F4 so I can't solve the problem.
SlimerDude Tue 26 Aug 2014
Yep - me! F4 under Win7 64 bit to be exact.
Right click, "Run As... Fantom Class" runs the class as a Fantom script. You are doing the right thing.
From your exception:
I imagine that the path does not exist. To check, in
fansh
type:(Note that
windows path
has been substituted with the, um, Windows path!)Anyway, I strongly suspect that you have a project mis-configured in F4.
F4 does not really deal with individual Fantom files, but rather Fantom projects so we need to ensure the project is setup correctly before we can run the classes / scripts.
In the project directory you will find 3 F4 text files,
.project
,.classpath
and.buildpath
(F4 hides these because they start with a dot, so use a normal Windows explorer / notepad to open them). If you post the contents of those 3 files ANDbuild.fan
I'll have a look and see what I can spot.Oh, and close ALL projects except the one with the examples.
rasa Tue 26 Aug 2014
Oh, I taught that "windows path" was some key. Sorry.
Note that I had to change backslash into forwardslash in order to execute File.os Otherwise fansh argued with: ERROR(17): Invalid escape sequence
Note that I've made a new project, so now the root folder is named FantomExamples. Inside that project I have only one folder named "fan" and 3 config files. 4th file build.fan seems to be aded uppon compiling, but I'm not sure about that. I have no idea why F4 reports that it cannot parse the path "C:\Users\rasa\f4workspace\FantomExamples\bin\fan" when the folder "bin" doesn't even exists?
.project
.classpath
.buildpath
build.fan
SlimerDude Tue 26 Aug 2014
I think I see.
When I mentioned F4 builds Fantom projects, more specifically I mean it builds Fantom pods. One F4 project builds one Fantom pod.
All the example files in the different directories can not (without modification) be built into a single pod. Mainly because to build a Fantom pod, all the class names in all the
.fan
files have to be different and all the.fan
files need to have different names.I imagine you have a couple of red crosses in your project, which looks like:
In F4, when you run a class as a script, it runs it from the built
.pod
. If you have errors / red crosses in your project (or problems in the Problems View) then the.pod
is not being built and you will not be able to run classes without error.So we're going change the
FantomExamples
project to just contain the files fromfan/sys/
directory. Delete the other directories and copy the contents offan/sys/
intofan/
and deletefan/sys/
. Refresh the project in F4 (Right-click on the project -> Refresh (F5)) and it should look like this:Note that
reflection.fan
needsfwt
added as dependency tobuild.fan
. Afterwards, yourbuild.fan
should look like:You project should now have no red crosses! And the Problems View should be clear. (
Window -> Show View -> Problems
if you can't see the Problems View).Now you should be able to right click on any
.fan
file, in either the Fantom Explorer View or the Editor, andRun As... -> Fantom Class
.If you're still having trouble, I've zipped up a working F4 project for the
sys
examples here: fantomExamples.zipMore Info on .pods
As mentioned earlier, F4 runs the class from the
.pod
file. By default the.pod
file is build to:So you can look for it there. If you clean the project (
Project -> clean...
) then the.pod
file should get rebuilt. So if you delete the.pod
file and clean the project, you should see it getting rebuilt.If the pod does not get re-built, you still have an error in your F4 project.
I've never tried to run the Fantom examples from within F4 before, and um, yes, it does not appear to be not straight forward.
@Brain n @Andy: What do you think about modifying the
examples/
dir so that it builds anexamples.pod
?Still have each file executable as a script, but maybe tidy up the class and file names so that they're all different and alter the
build.fan
so it has the correct dependencies and compiles all the examples into one pod?SlimerDude Tue 26 Aug 2014
Oh yeah... backslashes in URIs need to be escaped with a backslash:
(But if the project / pod wasn't being built then that would have been a red-herring anyway.)
rasa Wed 27 Aug 2014
OK, I understand, but I don't want to make many small projects as it is alredy possible to run all scripts inside NetBeans without slicing them into independable pods. So, i tried refactoring. I had to rename only 3 files:
depends = ["sys 1.0", "build 1.0", "compiler 1.0", "compilerJs 1.0", "concurrent 1.0", "email 1.0", "fwt 1.0", "gfx 1.0", "util 1.0", "web 1.0", "webmod 1.0", "wisp 1.0"]
Than, deleted netbeans folder as it is not necessary.
The only problem left is in the hellojava.fan Problems view says:
Don't know what is all about. Commented whole main method in this class to make F4 and its Problems view happy. Then I started other examples and everything was OK.
Here I have some questions and advices:
SlimerDude Wed 27 Aug 2014
Well done! I didn't want to give you any more extra steps!
hellojava.fan
replace the using line withThis imports / uses only the Java
System
class which prevents a conflict between the 2Void
classes. (Fantom and Java's.) The conflict is probably an F4 bug.Depends
class for version syntax.sys 1.0
actually meanssys 1.0.*
so it happily matchessys 1.0.66
; the current Fantom version.No, it uses whatever you put in
build.fan
.Note that you can only have ONE version of a pod in any given Fantom environment; which is hinted at by the fact
.pod
files don't have version numbers.rasa Wed 27 Aug 2014
p.s. How do I attach an image to the post?
SlimerDude Wed 27 Aug 2014
Click the down chevron next to the
Run As
button:And that brings up a list of recent Run Configurations. Whatever you ran last should be towards the top of the list.
To make sure you're using the correct version for the project!
Fantom pods are stored and managed with fanr.
You can't. You have to upload your image to somewhere on the web and link to it using the image syntax.
rasa Wed 27 Aug 2014
And, that's it? I always have to click on down chevron and then choose run configuration. It is impossible to set default run config or use keyboard shortcut?
SlimerDude Wed 27 Aug 2014
I googled:
and the top hit was Is there a shortcut in Eclipse to Re-run the most recently launched program?
rasa Wed 27 Aug 2014
OK. Where is that option in F4?
tomcl Sun 31 Aug 2014
Eclipse is maddening.
It is a very highly capable IDE, but when first learning it the things that you want to do with a simple project are more complex than you'd expect.
F4 still looks very good once it is properly configured - though because its developers seem to have stopped I do worry whether this will remain.
The things that are awkward for me: (1) standard compile and launch needing two clicks - the above key shortcut looks the best workaround, if it works (seems not to on my Mac). And anyway the twi clicks are not too bad.
(2) build & run (or build and debug) will run the last working version on compiler failure. Of course what you WANT is for the process to stop on compile failure.
This one is really annoying. The solution I've found is a bit messy but works. F4 "build" will run the build script. You can alter this by overriding the called method of Build so that compile failure will exit and not run the code.
(3) as the OP said, what is needed is a step by step bomb-proof tutorial for how to get started with F4 and Fantom so that those new to the language can get started on 64 bit win7 or (yuk) win8 without 3 hours checking configurations and experimenting. It is not simple because you have choice of 32/64 bit Java (and different versions) and 32/64 bit F4.
This tutorial needs to include stuff about how to set up your Fantom project and source file(s), how to alter build.fan to decent "compile and run only if compile succeeds" behaviour, etc. All if possible in a shrink-wrapped form.
SlimerDude Sun 31 Aug 2014
Ivan still does some tweaks now and then. The source is available on GitHub and can be built with maven.
Editors in general are a very personal thing... here is my take on your points:
Script Unit Test
view.Ivan did commit a fix for this, but in my opinion it (unfortunately) causes more issues than it fixes.
I think your idea of altering
build.fan
is probably the best for now.An Introduction to the F4 IDE
There are (and were) other issues that annoy me more. I listed most of them as GitHub Issues.
rasa Mon 1 Sep 2014
Vote here for IntelliJ IDEA plugin update.
rasa Thu 4 Sep 2014
I've managed to run examples in F4 successfully, but that was at my work site comp. Now I tried to do the same at home and failed with an already well known error:
I taught that I had resolved that error by doing all the steps above but it seems that I solved it accidentally. By comparing project and F4 configurations at home and at the work place I have discovered that all configs are identical. But then I compared project folders in file manager (not visible in project tree) and discovered that I really have the bin folder in my work comp and that there is no such folder in home comp. Here is how this folder looks like:
I have copied this folder into the project folder of my home comp and ran the examples without errors. The problem is that I'm not aware how I have created this folder structure at work comp? It's created by F4 but I don't know how and when that happened?
SlimerDude Thu 4 Sep 2014
From my observations, the directory structure (and pod) are created by F4 when the project successfully compiles for the first time. If your project never compiled then the directory structure (and pod) would not be created.
rasa Fri 5 Sep 2014
Not sure about that. There were no problems or warnings during compilation but project pod was not created.