create a link to a terminal command?
Hello,
Your local ignorant UNIX/Programmer here.
some engineers here are getting a Java app to finally work on MacOS X.
These guys have UNIX and Windows experience, but never touched a Mac before.
We can launch it via Terminal, and the icon appears in the Dock.. but when I right click the "application" in the terminal and tell it to keep it there, it won't actually launch anything once you quit.
The engineer was looking for a way like in Windows to be able to tell the shortcut to launch a certain file, etc...
Anyway... it was cool to see that without touching a single thing, a great deal of our software worked in about 10 minutes!
Now, off to getting it optimized with OSX specific calls...
Your local ignorant UNIX/Programmer here.
some engineers here are getting a Java app to finally work on MacOS X.
These guys have UNIX and Windows experience, but never touched a Mac before.
We can launch it via Terminal, and the icon appears in the Dock.. but when I right click the "application" in the terminal and tell it to keep it there, it won't actually launch anything once you quit.
The engineer was looking for a way like in Windows to be able to tell the shortcut to launch a certain file, etc...
Anyway... it was cool to see that without touching a single thing, a great deal of our software worked in about 10 minutes!
Now, off to getting it optimized with OSX specific calls...
Comments
You *could* save that command to a shell script file, then drag that file to the Dock. Unfortunately, it won't let you place it in the apps section, just the file section.
the file is in ~/Library/Java/Extensions/opensky.jar
Uh... btw, my engineers are gone now... how the hell do I get to root level of the HD? How do I get to Library/Java...
doing CD lets me go to root of my user account...
crap, why does this always look so easy when the others are zipping by it?
Originally posted by ZO
just a shortcut to get a .jar running...
the file is in ~/Library/Java/Extensions/opensky.jar
Uh... btw, my engineers are gone now... how the hell do I get to root level of the HD? How do I get to Library/Java...
In Terminal? 'cd /'
In Finder? Click on the hard drive icon in the sidebar, or hit shift-cmd-c and select it there.
doing CD lets me go to root of my user account...
crap, why does this always look so easy when the others are zipping by it?
Because they're driving.
And double-clicking the file in the Finder doesn't work because the Finder doesn't know about all the Terminal level apps, so it doesn't know what to do with the file you double-clicked.
- How do you start the Jar file? It says -bash: opensky.jar: command not found
- If and when this works again, how do I save it as a script? which parts do I save?
Type into it:
#!/bin/sh
java /Library/Java/Extensions/opensky.jar
Save this file where ever you want. Name it 'Opensky.command' When TextEdit gripes about the extension, override with 'don't append'.
In the Terminal, go to the folder where the above file is stored, and type 'chmod ugo+x Opensky.command' without the quotes. Hit return.
You should now be able to double-click *that* and run the .jar file.
You can also drop it into the (document section of the) Dock.
I dunno what my engineers did, but it worked for them... it doesnt here.
I double click the newly created Opensky.command file and it tells me (in the Terminal)
Exception in thread "main" java.lang.NoClassDefFoundError: /Library/Java/Extensions/opensky/jar
logout
[Process completed]
*sigh*
Anywya, dont worry... I'll just wait till tomorrow. Unless you want to try something else...
dammit man! it JUST WORKED when he gave a the path for that jar!! I've restarted the computer since... but I dont see why that would make a difference.
Thnaks for your time Kicka
Edit:
Found it.
Right click the jar file and choose "open with". Then goto /System/Library/CoreServices/Jar Launcher
If you do this in the info panel, you should be able to set it as default.
If you've got the Developer Tools installed, there's a program called Jar Bundler in /Developer/Applications/Java Tools/.
You can use this program to create a double-clickable Java .app (like other programs on Mac OS X). All the .jars used in the Java application can be stored in a subdirectory of the <program-name>.app folder.
There's also some Apple-proprietary classes that can be extended so that the application menu can be used successfully (quitting using cmd-q, getting preferences, interacting with the dock).
In reference to other instructions given:
Kickaha's instruction is slightly wrong. If the program is just a single .jar (with no dependencies apart from the standard Sun Java classes, and the manifest properly created to point to the class with the public static void main() method) then java -jar /Library/Java/Extensions/opensky.jar is the most appropriate command. If it has dependencies on other jars, then java -classpath <list of .jars separated by ':'> <name of class in opensky.jar with the public static void main() method) is the way to go.
EDIT:
I forgot to mention a reference for Java on Mac OS X:
Apple Reference Library - Java
That link will have instructions on how to use Jar Bundler, plus the Apple proprietary classes and more information.
Indeed, there are many other JAR files in the Extensions folder.
sorry... didnt know it was relevant..
And yes, I have dev tools installed.
ZO
Originally posted by Kickaha
Type into it:
#!/bin/sh
java /Library/Java/Extensions/opensky.jar
Not quite...
java -jar ~/Library/Java/Extensions/opensky.jar
Hope that helps. m.
Originally posted by ZO
Exception in thread "main" java.lang.NoClassDefFoundError: /Library/Java/Extensions/opensky/jar
You said before that it was in your home folder's Library folder. hence, you need the ~ before /Library/... for it to work. m.
Originally posted by Kickaha
Listen to him, I haven't used Java from the command line in a couple of years, and never on my Mac.
From what Apple does with building a GUI implemenation with Java, it is so much more elegant than windows counterparts.
But, then again, what isn't better on the Mac.
-walloo.
Now then... there is a ton of OS specific things that will have to be modified in the source to get it to work properly on OSX... but hopefully that will come soon.
Thanks for all your help
PS Anyone wanna beta test? ;-)
just kidding... its a Internet via Satellite app, so I doubt anyone will have any interest in it