alice-teacher Alice 2 command line

James Vanderhyde jvanderhyde at benedictine.edu
Mon Sep 23 10:47:47 EDT 2013


I figure out something about this issue myself. As Don said, this is an advanced topic, not directly related to teaching with Alice.

I was able to come up with a solution for opening an Alice 2 world on Mac by double-clicking the .a2w file. Here is what I did:

1. I figured out how to run the Alice Java program from the command line. This bypasses the Alice.app Mac OS X application. The benefit is that you can enter a .a2w file as a command-line parameter so Alice launches with that world open.
2. I put this in a shell script.
3. I embedded the shell script in an Automator script.
4. I associated .a2w files with the Automator script.

More details below. Thanks.

James


P.S. Detailed instructions.

1. Launch Automator from Applications. Create a new "Application."
2. Find the "Run Shell Script" action under Utilities and drag it into the "drag actions here" pane.
3. Copy and paste this shell script into the Run Shell Script action (replace what's there).
#----------Copy this code-----------
cd /Applications/Alice.app/Contents/Required
/System/Library/Frameworks/JavaVM.framework/Versions/1.6/Commands/java -classpath ./externalLib/getopt-1.0.7.jar:./jython-2.1/jython.jar:./lib/alice.jar:./externalLib/jogl.jar:./externalLib/gluegen-rt.jar:./externalLib/resolver.jar:./externalLib/vecmath.jar:./externalLib/xercesImpl.jar:./externalLib/xml-apis.jar:./externalLib/xmlParserAPIs.jar:./externalLib/customizer.jar:./externalLib/jmf.jar:./externalLib/mediaplayer.jar:./externalLib/multiplayer.jar:./externalLib/mp3plugin.jar -Dpython.home=jython-2.1 -Djava.library.path=/Applications/Alice.app/Contents/Required/lib/osx -Xincgc -Xmx512m edu.cmu.cs.stage3.alice.authoringtool.JAlice "$1"
#----------stop copying here-----------
4. In the Run Shell Script action, find the popup menu labeled "Pass input." Change this to "as arguments."
5. Save the Automator workflow as "Open in Alice" or whatever you want. Put in the Applications folder or wherever you want.
6. If you double-click your new "Open in Alice" workflow, Alice will launch as a Java Application. The Queen will appear with an error message, but it's because there was no .a2w file to open. Alice should still work normally, however. (Exit Alice for now.)
7. Now, in the Finder, right-click on any .a2w Alice 2 world file, and choose "Get Info."
8. In the Info window, there is an "Open with" area. Choose your "Open in Alice" Automator workflow there. Also, click the "Change All…" button.

Now double-clicking an .a2w file should open the world in Alice. I haven't tested it thoroughly, but it seems like it works. I'm not sure if the Java libraries list or the java command in the shell script will be exactly the same on everyone's computer, and with every version of Alice. But this combo worked for me. I have Mac OS X 10.8.5 and Alice 2.3.5.

Known Issues:
1. This bypasses the Alice.app OS X application completely, so you won't see the Alice application icon in the Dock. It just looks like the standard Java icon.
2. If you try to double-click a .a2w file while the Automator script is running on another file, nothing seems to happen, until you quit Alice, at which point the Automator script starts over and launches Alice again with file you double-clicked.
3. There is no way to use this to open a .a2w file if Alice is already running, because it used the command-line parameter to tell the Alice Java program what world to start with.

--
Dr. James Vanderhyde
Math and Computer Science
Benedictine College
jvanderhyde at benedictine.edu<mailto:jvanderhyde at benedictine.edu>
http://vanderhyde.us/~james/pro/



On Sep 21, 2013, at 10:46 AM, Don Slater <dslater at andrew.cmu.edu<mailto:dslater at andrew.cmu.edu>> wrote:

Warning: This is an advanced topic and may be of limited interest to many members of the list… But it applies to the recent thread on double-clicking an Alice project file and having it launch Alice, as opposed to having to open Alice project files from within Alice...

<begin answer>

It is possible to launch Alice from the Terminal command line in OS X using:

open -a <path to the directory containing the Alice app on your system>/Alice.app/Contents/MacOS/Alice

on my machine, where Alice 2.3 located in my system Applications directory, I can type:

open -a /Applications/Alice.app/Contents/MacOS/Alice

Unfortunately, the open command does not take arguments, such as file names, to link the project file to the application…

There may be an alternative command that I have not yet found…

We will look into the double-click on an .a2w or .a3p to launch Alice issue…

All the best,
Don Slater

On Sep 20, 2013, at 9:30 PM, James Vanderhyde <jvanderhyde at benedictine.edu<mailto:jvanderhyde at benedictine.edu>> wrote:

Is there a way to launch Alice 2 from the command line, and if so, is one of the command-line parameters the Alice 2 world file to load? If so, I could use this information to open .a2w files by double-clicking the file, which otherwise doesn't work on Mac OS X.

James
--
Dr. James Vanderhyde
Math and Computer Science
Benedictine College
jvanderhyde at benedictine.edu<mailto:jvanderhyde at benedictine.edu>
http://vanderhyde.us/~james/pro/



_______________________________________________
alice-teachers mailing list
alice-teachers at lists.andrew.cmu.edu<mailto:alice-teachers at lists.andrew.cmu.edu>
https://lists.andrew.cmu.edu/mailman/listinfo/alice-teachers

_______________________________________________
alice-teachers mailing list
alice-teachers at lists.andrew.cmu.edu<mailto:alice-teachers at lists.andrew.cmu.edu>
https://lists.andrew.cmu.edu/mailman/listinfo/alice-teachers

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.andrew.cmu.edu/pipermail/alice-teachers/attachments/20130923/4e0fec15/attachment.html 


More information about the alice-teachers mailing list