How to use fcshWrapper

Download the binaries [FCSH Wrapper 0.1.2], unpack to any directory you want. Specify FCSHWRAPP_HOME property to point to the directory where you unpacked the binaries, FLEX_HOME to your flex sdk directory. FCSHWRAPP_JRE and FCSHWRAPP_PORT are not mandatory.

FCSHWRAPP_JRE must point to a jre 1.5 or higher, but if it is not specify, the jre used to lunch the wrapper will be searched in JAVA_HOME then JRE_HOME. If none of these are specified, it relays on the system PATH to lunch the wrapper. The default port on which the wrapper accepts commands is 52795. If you wont another port you can specify it on the FCSHWRAPP_PORT property.

A sample build file using fcshWrapper:

<?xml version="1.0" encoding="UTF-8"?>
<project name="changeme" default="all" basedir=".">
   <property name="FCSHWRAPP_PORT" value="52797"/>
   <property name="FCSHWRAPP_JRE" value="C:/Program Files/Java/jdk1.5.0_11"/>
   <property name="FCSHWRAPP_HOME" value="d:/fcshWrapper-bin/bin"/>
   <property name="FLEX_HOME" value="c:/flex-sdk"/>
   <path id="mypath">
       <fileset dir="${FCSHWRAPP_HOME}" includes="fcshWrapper.jar"/>
   <taskdef name="fcsh" classname="ro.arhinet.fcshwrapper.ant.FcshTask">
       <classpath refid="mypath"/>
   <target name="all">
       <fcsh command="mxmlc">
           <arg value="c:\ArhiNET.project\arhinet\web\flex-pages\app1.mxml"/>
           <arg value=" "/>

Unfortunately I have build the application to work only on windows, but with some minor changes (another jdic binaries and removing '.exe' hardcoded calls in code) can be made to run on any other platform.

The first time the ant task is called, it observes that nobody is listening on the specified port and auto-lunches the wrapper as a separate process that can be observed on the system tray.

The output of the fcsh.exe is redirected to the ant task. The ant task fails if there is an error compiling flex files. The fcshWrapper remember the commands received and their assigned ids by the fcsh.

The wrapper stays on the system tray and notifies you when the build fails.

And there is also a console with all the commands received by the wrapper that can be hided/displayed from the system tray.


Brad said...

As a note, as far as I can tell this requires Ant 1.7 - tried it on Ant 1.6.5 and it bailed out due to a missing method: Project.log(String,Throwable,int) (Ant Javadocs say the method was added in 1.7)

Mihai Vasilache said...

Hey Brad!

If this is the only issue with Ant 1.6.5 then it can be fixed quickly. I do not have in mind any compatibility issues because i made this to serve to my new project. Unfortunately i don't have time these days to make changes. There is also another post from a guy asking me why is not working with Flashdevelop. I do not have time to look. So, if you want to make changes i can make you an account on sourceforge.


quinrou said...

This is awesome!!
Any chance to get this for MACs too?

Flavio said...

Hi Mihai

I've trying to use FCSH Wrapper on my project but we're having problems with some warnings shown in the compilation process (what is good!) that are causing the build to fail (what is terrible!).
Is there any workaround to avoid this behavior?

Mihai Vasilache said...

I can try to remove this warnings. I will look in a couple of hours when i arrive home. Can you tell me what warnings you have?

Flavio said...


I haven't checked the source code but I believe it happens because you sending the warning message to SDTERR. If you send the warning messages to STDOUT and errors to STDERR maybe it will work fine...

Check the example bellow...

Nobody listening on 52797...
[Wrapper STDOUT] Subprocess initialization ok!
Deataching from subprocess!
<-- BEGIN --Wrapper STDOUT--:
Server started on port 52797
[FCSH initalized]
--> END --Wrapper STDOUT--;
[Wrapper STDERR] terminated!
<-- BEGIN --Wrapper STDERR--:

--> END --Wrapper STDERR--;
Adobe Flex Compiler SHell (fcsh)
fcsh: Assigned 1 as the compile target id
Loading configuration file E:\WDK-Alpha\Webdesk3Flex\flex-config-mxmlc.xml
E:/WDK-Alpha/Webdesk3Flex/bin/Webdesk.swf (1261135 bytes)

fcsh: Assigned 2 as the compile target id
Loading configuration file E:\WDK-Alpha\Webdesk3Flex\flex-config-mxmlc.xml
E:/WDK-Alpha/Webdesk3Flex/bin/WebdeskZoom.swf (335714 bytes)

(fcsh) fcsh: Assigned 3 as the compile target id
Loading configuration file E:\WDK-Alpha\Webdesk3Flex\flex-config-mxmlc.xml
E:/WDK-Alpha/Webdesk3Flex/bin/AreaView.swf (481561 bytes)

(fcsh) fcsh: Assigned 4 as the compile target id
Loading configuration file E:\WDK-Alpha\Webdesk3Flex\flex-config-mxmlc.xml
E:/WDK-Alpha/Webdesk3Flex/bin/Administration.swf (757283 bytes)

E:\WDK-Alpha\Webdesk3Flex\FlexSource\com\datasul\technology\webdesk\administration\Administration.mxml: Warning: The type selector 'RadioButton' was not processed, because the type was not used in the application.

E:\WDK-Alpha\Webdesk3Flex\build.xml:68: The following error occurred while executing this line:
E:\WDK-Alpha\Webdesk3Flex\build.xml:60: The following error occurred while executing this line:
E:\WDK-Alpha\Webdesk3Flex\build.xml:38: Compile failed!

Total time: 2 minutes 16 seconds

Flavio said...


I started a fast investigation trying to solve the warning failure and I believe I discovered what's going on.

fcsh (and not your classes) send the warnings to stderr and you classes check if something was written on this stream to detect failure.

the workaround could be to read the stderr message returned by fcsh and check if it matches the [file]: warning: [message] pattern. It it does, you could just redirect the text to stdout channel instead of the current behavior. Not that elegant, I know, but fast. :)

Mihai Vasilache said...

Hello Flavio,

I arrived home and just opened the computer.
I expected to be that.
The solution proposed by you seams to be the only one. First i will look if there are some settings to send to fcsh for that...
I will try to make the change tonight (i am in Romania GMT+03), but i do not promise anything. If you like i can give you rights on sourceforge.

Mihai Vasilache said...

I searched a little on net. I found this:

"Errors and warnings are reported differently, depending on which compiler you are using. The mxmlc and compc command-line compilers send error and warning messages to the standard output."....
Maybe you can send me your email (mihai dot vasilache at gmail). Now i am very tired and i am going to sleep.

kamesh said...

I tried to implement the sample program which you have mentioned in the blog. My build failed with the following trace.

" C:\Fwrapper>ant -f c:\Fwrapper\testScript.xml
Buildfile: c:\Fwrapper\testScript.xml

Nobody listening on 52797...
Timeout detected!
Aborting lunch!
[Wrapper STDOUT] terminated!
-- BEGIN Wrapper STDOUT:
[Wrapper STDERR] terminated!
Finishing connection:

-- END Wrapper STDOUT;
Finishing connection:
Finishing connection:
-- BEGIN Wrapper STDERR:
Exception in thread "main" java.io.IOException: CreateProcess: C:\cc_temp\kaparame-aug31\counterpoint\cp\dev\flexsdk\bin\fcsh.exe error=2
at java.lang.ProcessImpl.create(Native Method)
at java.lang.ProcessImpl.[init](ProcessImpl.java:81)
at java.lang.ProcessImpl.start(ProcessImpl.java:30)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:451)
at ro.arhinet.fcshwrapper.wrapper.FcshProcessWrapper.[init](FcshProcessWrapper.java:39)
at ro.arhinet.fcshwrapper.wrapper.FcshProcessWrapper.startFcshProcess(FcshProcessWrapper.java:31)
at ro.arhinet.fcshwrapper.wrapper.Main.main(Main.java:19)
-- END Wrapper STDERR;

c:\Fwrapper\testScript.xml:17: Unable to send command to server!

Total time: 11 seconds
C:\Fwrapper>ant -f c:\Fwrapper\testScript.xml. "

So what this exactly means... Does the wrapper expects fcsh.exe to be there somewhere in my project specific location???????????