Home > JAVA JIF > Compile and Run JIF Programs Using JIF Compiler

Compile and Run JIF Programs Using JIF Compiler

First Build JIF Compiler using Apache ant, find all steps here:
JIF (Java Information Flow) Compiler Building Using Ant in ubuntu and windows

Compile and Run JIF Programs steps:

  1. After building JIF compiler, we can try this compiler by executing a sample demo program available in $jif/examples i.e. battleship. To compile and run the battleship example follow the below steps;
  2. Ensure that the principals Alice and Bob are present. The code for the principals is in the $JIF/tests directory. To compile the code for the principals, perform the following commands.
    mohsin@mohsin-laptop:~/jif-3.3.1/tests$  jifc /home/mohsin/jif-3.3.1/tests/jif/principals/Alice.jif /home/mohsin/jif-3.3.1/tests/jif/principals/Bob.jif
  3. Also add the path in CLASSPATH environmental variable like below;
    export CLASSPATH=$CLASSPATH:$JIF/test/
  4. Compile the BattleShip classes, perform the following command.
    mohsin@mohsin-laptop:~/jif-3.3.1/examples/battleship$ jifc -classpath $JIF/tests *.jif
  5. Execute the BattleShip Example by running the following command.
    mohsin@mohsin-laptop:~/jif-3.3.1/examples/battleship$ jif -classpath $JIF/tests Main
  6. Output:
    Playing battleships, with each player having 10 covered coordinates

Initializing…. Done.
Playing rounds…
Alice: (0, 0)?  N   Bob: (0, 0)?  N   Score: 0 vs. 0
Alice: (1, 0)?  N   Bob: (1, 0)?  N   Score: 0 vs. 0
Alice: (0, 1)?  N   Bob: (0, 1)?  N   Score: 0 vs. 0
Alice: (0, 2)?  N   Bob: (0, 2)?  N   Score: 0 vs. 0
Alice: (1, 1)?  Y   Bob: (1, 1)?  Y   Score: 1 vs. 1
Alice: (2, 0)?  N   Bob: (2, 0)?  N   Score: 1 vs. 1
Alice: (3, 0)?  N   Bob: (3, 0)?  N   Score: 1 vs. 1
Alice: (2, 1)?  N   Bob: (2, 1)?  N   Score: 1 vs. 1
Alice: (1, 2)?  N   Bob: (1, 2)?  N   Score: 1 vs. 1
Alice: (0, 3)?  N   Bob: (0, 3)?  N   Score: 1 vs. 1
Alice: (0, 4)?  N   Bob: (0, 4)?  N   Score: 1 vs. 1
Alice: (1, 3)?  Y   Bob: (1, 3)?  Y   Score: 2 vs. 2
Alice: (2, 2)?  Y   Bob: (2, 2)?  Y   Score: 3 vs. 3
Alice: (3, 1)?  N   Bob: (3, 1)?  N   Score: 3 vs. 3
Alice: (4, 0)?  N   Bob: (4, 0)?  N   Score: 3 vs. 3
Alice: (5, 0)?  N   Bob: (5, 0)?  N   Score: 3 vs. 3
Alice: (4, 1)?  N   Bob: (4, 1)?  N   Score: 3 vs. 3
Alice: (3, 2)?  Y   Bob: (3, 2)?  Y   Score: 4 vs. 4
Alice: (2, 3)?  N   Bob: (2, 3)?  N   Score: 4 vs. 4
Alice: (1, 4)?  Y   Bob: (1, 4)?  Y   Score: 5 vs. 5
Alice: (0, 5)?  N   Bob: (0, 5)?  N   Score: 5 vs. 5
Alice: (0, 6)?  N   Bob: (0, 6)?  N   Score: 5 vs. 5
Alice: (1, 5)?  N   Bob: (1, 5)?  N   Score: 5 vs. 5
Alice: (2, 4)?  N   Bob: (2, 4)?  N   Score: 5 vs. 5
Alice: (3, 3)?  N   Bob: (3, 3)?  N   Score: 5 vs. 5
Alice: (4, 2)?  Y   Bob: (4, 2)?  Y   Score: 6 vs. 6
Alice: (5, 1)?  N   Bob: (5, 1)?  N   Score: 6 vs. 6
Alice: (6, 0)?  N   Bob: (6, 0)?  N   Score: 6 vs. 6
Alice: (7, 0)?  N   Bob: (7, 0)?  N   Score: 6 vs. 6
Alice: (6, 1)?  N   Bob: (6, 1)?  N   Score: 6 vs. 6
Alice: (5, 2)?  N   Bob: (5, 2)?  N   Score: 6 vs. 6
Alice: (4, 3)?  N   Bob: (4, 3)?  N   Score: 6 vs. 6
Alice: (3, 4)?  Y   Bob: (3, 4)?  Y   Score: 7 vs. 7
Alice: (2, 5)?  N   Bob: (2, 5)?  N   Score: 7 vs. 7
Alice: (1, 6)?  N   Bob: (1, 6)?  N   Score: 7 vs. 7
Alice: (0, 7)?  N   Bob: (0, 7)?  N   Score: 7 vs. 7
Alice: (0, 8)?  N   Bob: (0, 8)?  N   Score: 7 vs. 7
Alice: (1, 7)?  N   Bob: (1, 7)?  N   Score: 7 vs. 7
Alice: (2, 6)?  N   Bob: (2, 6)?  N   Score: 7 vs. 7
Alice: (3, 5)?  Y   Bob: (3, 5)?  Y   Score: 8 vs. 8
Alice: (4, 4)?  N   Bob: (4, 4)?  N   Score: 8 vs. 8
Alice: (5, 3)?  N   Bob: (5, 3)?  N   Score: 8 vs. 8
Alice: (6, 2)?  N   Bob: (6, 2)?  N   Score: 8 vs. 8
Alice: (7, 1)?  N   Bob: (7, 1)?  N   Score: 8 vs. 8
Alice: (8, 0)?  N   Bob: (8, 0)?  N   Score: 8 vs. 8
Alice: (9, 0)?  N   Bob: (9, 0)?  N   Score: 8 vs. 8
Alice: (8, 1)?  N   Bob: (8, 1)?  N   Score: 8 vs. 8
Alice: (7, 2)?  N   Bob: (7, 2)?  N   Score: 8 vs. 8
Alice: (6, 3)?  N   Bob: (6, 3)?  N   Score: 8 vs. 8
Alice: (5, 4)?  N   Bob: (5, 4)?  N   Score: 8 vs. 8
Alice: (4, 5)?  N   Bob: (4, 5)?  N   Score: 8 vs. 8
Alice: (3, 6)?  Y   Bob: (3, 6)?  Y   Score: 9 vs. 9
Alice: (2, 7)?  N   Bob: (2, 7)?  N   Score: 9 vs. 9
Alice: (1, 8)?  N   Bob: (1, 8)?  N   Score: 9 vs. 9
Alice: (0, 9)?  N   Bob: (0, 9)?  N   Score: 9 vs. 9
Alice: (0, 10)?  N   Bob: (0, 10)?  N   Score: 9 vs. 9
Alice: (1, 9)?  N   Bob: (1, 9)?  N   Score: 9 vs. 9
Alice: (2, 8)?  N   Bob: (2, 8)?  N   Score: 9 vs. 9
Alice: (3, 7)?  Y
Alice won!

Categories: JAVA JIF
  1. sara
    June 3, 2012 at 12:02 pm

    thanks again for your useful notes

  2. sara
    June 3, 2012 at 12:34 pm

    Also add the path in CLASSPATH environmental variable like below;
    export CLASSPATH=$CLASSPATH:$JIF/test/

    test should be tests

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: