Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Using command line arguments for a bundle java app?[SOLUTION]



Thanks for your comments. I apologize if this seemed a trivial question.

My application is a bundled java application (created with jarbundler). Although it's easy to run through the command line using it's options, I need to distribute it as a Mac bundle with icons etc. However, I've been asked to replicate the Windows feature of running it with the options. This is so we can run it in either admin or client modes over a network (some features are disabled in the client mode).

If I call:

% ./MyApp.app/Contents/MacOS/JavaApplicationStub -client

The application works as expected. (I was calling the ..../Java/XXX.jar file directly which lost all the nice Mac features.)

This now means I can set up unix style scripts to accomplish the same as the Windows environment. Thanks again.

A/Prof David Darby
Em email@hidden

Begin forwarded message:

From: email@hidden
Date: 29 September 2004 1:49:04 AM
To: email@hidden
Subject: Re: Using command line arguments for a bundle java app?

David Darby wrote:
| How do I pass arguments to my bundled application using the command
| line?

Broadly, you don't. If your application is bundled, it's set up to be run by double-clicking, and double-clicking has no provision for command arguments. There is a way to pass a *fixed* set of arguments, using the Info.plist file[1], but I believe that
it's specific to Java 1.4. If you want something that works for any version of Java, you're probably better off providing a separate Mac-specific main() which supplies whatever you need as "arguments".


If what you're asking is how to run your bundled application from the command line, passing it *non-fixed* arguments, then you specify the executable file directly:

    % ./MyApp.app/Contents/MacOS/MyApp -foo

| For example, I have an application bundle called "MyApp.app". I
| wish to pass the -foo argument to it when I open it using the command
| line. I've tried "open MyApp.app -foo" and other combinations but the
| arguments are ignored.

Because "open" runs an application the same way double-clicking does, and double-clicking doesn't support arguments.

Overall, it appears you're under the misbelief that OS X runs Java applications the same way Windows does: by simulating the command line. It doesn't. The command line in OS X is simply one of several ways by which programs can be run.

Glen Fisher


[1] http://developer.apple.com/documentation/Java/Reference/ Java14JavaDict/Introduction/chapter_1_section_1.html#//apple_ref/doc/ uid/TP40000886-CH203



_______________________________________________ Do not post admin requests to the list. They will be ignored. Java-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/java-dev/email@hidden

This email sent to email@hidden


_______________________________________________ Do not post admin requests to the list. They will be ignored. Java-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/java-dev/email@hidden

This email sent to email@hidden


Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.