Mailing Lists: Apple Mailing Lists

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

Re: AppleEvents from a multiplatform Java app?



Alexander Lohse <email@hidden> wrote:

>I was searching a lot through the net , but I could not find any hint
>how to be able to fire applevents or applescripts from a java
>application.

If all you want to do is execute scripts, I suggest using the command
'osascript' and System.exec(String[]).  See 'man osascript' in Terminal for
the command's details.

If your scripts have pathnames in Java form (e.g "/etc"), you will probably
need the 'POSIX file' class, which is documented in the scripting
dictionary of StandardAdditions.osax.  It's listed under Miscellaneous
Commands on my machine.  Simple examples:
  osascript -e 'path to startup disk as string'
  osascript -e '"/etc" as POSIX file'
  osascript -e 'POSIX path of (path to startup disk)'


>Can anyone give me hint how to embedd Appescript in my crossplattform
>Java app?
>I can go very well with code like:
>if (System.getProperty("mrj.version") == null) { ... }
>or reflection-method-calls
>
>But I would not like to maintain platformspecific source code.

AppleScript itself is platform-specific to Mac OS.  If you want to fire
AppleEvents or run AppleScripts, then that part of your program is
necessarily platform-specific.

Even if you use an external command like 'osascript', the scripting
commands themselves and the use of exec() will be platform-specific.

Exactly what are you trying to do by running scripts?  Or are you just
trying to add a general scripting facility to your Java program?

  -- GG


 _______________________________________________
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.