Launching steam from Java.

1 view
Skip to first unread message

mikel

unread,
Feb 7, 2009, 10:06:56 PM2/7/09
to Cappuccino & Objective-J
Hey guys,

Basically, I'm trying to run steam from Java using the Runtime exec()
command (I'm using Mac OS X 10.5.6).

Given that this technique is by no means as powerful as using the
Terminal itself, I suspect the reason it's not working is because of
the environment variables, and the way these are set when I fire up
Terminal.app. So, when I do it through the Terminal, I can "steam
create projectNameHere" no problem. This exact functionality is
precisely what I would like to get working from Java.

My shell batch handling class reports back saying that steam was not
found as a valid command.

So I've decided to dig a little deeper and look inside the steam
script, to see what exactly is happening there. At the end of the
file, I found this:

java -classpath $CLASSPATH steam $@

So I tried calling this manually from the terminal, where the
classpath is equal to CLASSPATH="$OBJJ_LIB:$OBJJ_LIB/js.jar" - I
specified the relative path to this js.jar file inside the
corresponding folder in my objj directory (usr/local/share/objj).

When I do that (namely, exactly this: java -classpath js.jar steam), I
get that

Exception in thread "main" java.lang.NoClassDefFoundError: steam

despite steam.class being right there.

So I try java steam.class and I get

Exception in thread "main" java.lang.NoClassDefFoundError: org/mozilla/
javascript/Script
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:675)
......

Any ideas as to why this is happening? Does anybody know of a clean
way to invoke steam from Java's runtime?

Thanks in advance everyone!

Cheers.

Leif Singer

unread,
Feb 7, 2009, 10:34:36 PM2/7/09
to objec...@googlegroups.com
Hello mikel,

basically, you're correct. You need to call:

java -classpath $CLASSPATH steam

But in $CLASSPATH, you need two entries: the js.jar as well as the
steam.class. As you might know, in Java, you add JAR files to the
classpath directly, whereas you add class files by giving just the
path to the file (excluding package directories). So in my case, the
following works:

java -classpath $CAPPUCCINO_DIR/Tools/Utilities/js.jar:
$CAPPUCCINO_DIR/objj_build/Release/steam/lib/ steam

$CAPPUCCINO_DIR being the directory created by checking Cappuccino out
from github. Of course, I've also built the project with ant.

Hope I could help.
-- Leif

mikel

unread,
Feb 7, 2009, 10:47:58 PM2/7/09
to Cappuccino & Objective-J
Hey Leif,

Thanks for your answer, that sure clarifies things a bit.

For some unknown reason, I have the js.jar file in the Utilities
folder inside of the home cappuccino directory, however, I cannot seem
to find the objj_build one. I built everything following the
instructions on github (I remember using ant bootstrap to do it).

Could this folder be located somewhere else?

When I enter "steam" in Terminal.app, I do get the following warning:

OBJJ_HOME not set, defaulting to /usr/local/share/objj

so I wonder if it has anything to do with that. If there is no easy
way to fix this, maybe I'll just dump everything and build from
scratch.

I've looked around for that steam/lib folder and haven't been able to
find anything yet.

Cheers!

mikel

unread,
Feb 8, 2009, 7:44:00 PM2/8/09
to Cappuccino & Objective-J
Hmm, I've been fiddling with this all day long and really can't seem
to figure out what the heck is going on.

I just haven't been able to find that objj_build folder you reference
in your post.

What's the easiest way to wipe everything out and reinstall? Is it
enough if I remove my cappuccino folder (the one in my home folder)
along with /usr/local/share/objj or is there some other stuff that I
also need to remove prior to installing from scratch?

Thanks!

Francisco Tolmasky

unread,
Feb 8, 2009, 7:52:10 PM2/8/09
to Cappuccino & Objective-J
Have you set your STEAM_BUILD environment variable? The build
directory is the same as that. If you haven't, then Cappuccino won't
build correctly. (By default, projects build inside their project
directories and not a shared build directory).

export STEAM_BUILD=whereveryouwantbuildproductstogo

mikel

unread,
Feb 8, 2009, 7:57:01 PM2/8/09
to Cappuccino & Objective-J
Francisco,

I thought I had set it correctly yeah, as steam works perfectly fine
by itself when invoked from Terminal.app.

Do you think that my not finding of the objj_build folder means that
capuccino was never built correctly in the first place?

Without being able to reference that folder directly, it doesn't looks
like I will be able to call steam from Java through exec().

I guess I might as well just throw everything out and reinstall. Are
the two folders I mentioned in me previous post all I have to remove
before reinstalling?

Cheers.

Leif Singer

unread,
Feb 8, 2009, 8:13:10 PM2/8/09
to objec...@googlegroups.com
mikel,

did you actually ever build Cappuccino from source or did you just
download the starter pack? You only need the objj_build folder for
getting at the steam.class file, and if I remember correctly you
already mentioned you had that. So where do you have that class file?
-- Leif

mikel

unread,
Feb 8, 2009, 8:25:35 PM2/8/09
to Cappuccino & Objective-J
I built it from source so I could use steam.

I just got it to work by calling it this way:

java -classpath /Users/mikel/cappuccino/Tools/Utilities/js.jar:/Users/
mikel/cappuccino/Tools/steam/\$\{env.STEAM_BUILD\}/Release/steam/lib/
steam

I didn't find the objj_build folder per se, but whatever, the same
files are also in that lib folder.

In any case, thanks everyone for the help. As always, you guys are
tremendously dependable!

Cheers.

Leif Singer

unread,
Feb 8, 2009, 8:38:20 PM2/8/09
to objec...@googlegroups.com
mikel,

looks like when you built, $STEAM_BUILD wasn't set, so Ant created a
directory with the literal name of the variable -- ${env.STEAM_BUILD}.
So that's your build folder I was referring to. This happened to me
once as well, though I don't remember whether that was because I
hadn't set the variable or I used an outdated version of the build
scripts.

What are you trying to do, anyway? :)
-- Leif

mikel

unread,
Feb 8, 2009, 8:41:34 PM2/8/09
to Cappuccino & Objective-J
That must be it yeah, damn, I can't believe I forgot that.

Do you think it will present any more problems like this down the
line?

For now, I'm working on this tool involving Java and Cappuccino, just
a crazy idea of mine!

Thanks Leif, your help is much appreciated!

Leif Singer

unread,
Feb 8, 2009, 9:24:20 PM2/8/09
to objec...@googlegroups.com
> That must be it yeah, damn, I can't believe I forgot that.
>
> Do you think it will present any more problems like this down the
> line?
Just to be on the safe side, set the variable properly (to something
like obbj_build in the Cappuccino directory) and rebuild Cappuccino.
Then call ´ant´ from Cappuccino's root directory (where the build.xml
resides). You can then remov the wrong directory.

> For now, I'm working on this tool involving Java and Cappuccino, just
> a crazy idea of mine!
I'm curious about the results! If you can, keep the list updated about
your efforts.

> Thanks Leif, your help is much appreciated!
My pleasure.
-- Leif
Reply all
Reply to author
Forward
0 new messages