#2437 Powershell scripts for running Fantom

matthew Mon 27 Jul 2015

I recently pushed a changeset that adds some Windows powershell scripts for running the standard tools that are shipped with Fantom in the \bin directory. It is intended that these eventually replace the 32-bit executables that are currently used to run Fantom on windows.

One of the issues that using powershell scripts solves is that the executables are only able to run a 32-bit jvm. The scripts allow us to run using any jvm on the host. It will use the default (system) jvm first; but that can be overridden by setting either the FAN_JAVA or JAVA_HOME environment variable (just like in the unix scripts)

I took a similar approach to how we run fantom on unix. There is a fanlaunch.ps1 script that handles setting up the environment and launching the jvm for a particular tool. Then there are a bunch of scripts (fan.ps1, fant.ps1, etc) that use that to launch the appropriate tool.

If anyone is using windows and would be willing to try them out and provide feedback that would be great. Especially if there are any powershell gurus out there who can provide any suggestions on the scripts.

Just a note: By default, windows powershell security permissions do not allow the execution of local scripts. You will have to run powershell as Administrator (elevated mode) and run this command:

C:\> Set-ExecutionPolicy RemoteSigned

Then, in a normal powershell, you will be able to run the scripts as:

C:\Dev\fantom\fan> .\bin\fan.ps1 -version

matthew Mon 27 Jul 2015

After some more thought, we have decided to switch to good old windows batch files for this. The security restrictions around powershell might raise more problems than it solves, and we can achieve an equivalent launcher using batch files. So I've pushed some new changesets that remove the powershell scripts and replace them with batch file.

If anyone is willing to try these out and provide feedback that would be great. Thanks.

SlimerDude Wed 29 Jul 2015

Batch files, cool! Brian suggested the logic would be too complicated for batch files, but I'm pleased that's not the case!

So line 49 of fanlaunch is currently:

SET JAVA="%JAVA_HOME%"

but that gives me:

'"C:\Apps\Java\jdk1.6.0_45"' is not recognized as an internal 
or external command, operable program or batch file.

Changing it to:

SET JAVA="%JAVA_HOME%\bin\java"

works better.

Also, the first few set commands are executed before the first setlocal. Not a big thing, but it does pollute your environment variables on the command line.

Once these batch files are in, and Fantom supports 64 bit JDKs on Windows, does that mean the next Fantom release will also ship with a 64 bit Windows swt.jar? (He asks hopefully!)

matthew Wed 29 Jul 2015

Good catch. I just pushed a changeset with fixes for both those things. Not sure yet about the 64-bit swt.jar

matthew Thu 30 Jul 2015

I also pushed some more changes to handle bootstrapping a development environment on Windows now that we are switching to batch scripts. One of the bigger changes there is that you no longer have to configure the runtime.substitutes property in etc/sys/config.props. So that should make things simpler. I've updated the docs also for all these changes as well.

So, if anyone is able to sanity check those changes, that would be great. Thanks!

Login or Signup to reply.