# How do I set up files of a specified extension to open in a Java application?



## hbquikcomjamesl (Aug 8, 2012)

We have an internally developed Java application ("emulator.jar"), an IBM 5250 terminal emulator Telnet client, that saves its parameters in a file with an extension of ".5250" for unsecured sessions, or ".5250s" for secured ones. It's designed to be launched by double-clicking on such a configuration file's icon; as such, it has the capability to save configuration files from a toolbar button, but it only loads them on launch. It accepts the fully-qualified pathname of the configuration file as a parameter. 

Under WinDoze, associating .5250 and .5250s files is a matter of defining those file types in "Folder Options," with an "open" operation mapped into a command line like

"C:\Program Files\Java\jdk1.6.0_12\jre\bin\java.exe" -jar J:\emulator\jars\emulator.jar "%1"

(varying, of course, on where java.exe lives, and where emulator.jar lives).

But to my great surprise and outrage, doing the equivalent on a Mac appears to be somewhat akin to pulling the teeth of whatever large predatory cat the installed OS happens to be named after, without benefit of an anesthetic.

So far, I've learned how to make an application bundle out of the jar, with Jar Bundler. And I've even successfully hard-coded the pathname of a configuration file under "Arguments to Main," but creating a new application bundle around a 200k JAR for every single configuration file (can an application bundle contain an alias? Hmm.) is not a solution.

And I've learned how to create a simple AppleScript that makes a command-line call to launch the emulator, but that's not much better, given that it's a big, nasty, extra step, and the resulting application bundles still end up around 100k.

Another weird thing about this business is that for some reason, Get Info sees the configuration files for the emulator as Unix executables, which they most certainly are NOT.


----------

