[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[MacPerl] Re: Launch



At 04.36 -0500 1998.05.22, you wrote:
>Could I use Mac::Apps::Launch to start multiple instances of
>the Mac Java Runtime (MRJ), each running adifferent Java
>Application ?

MRJ is like every other app, you can only launch it once; however, you can
have MRJ run more than one Java app at once.

But if for some reason you can't do that, this is what I would try to do to
get around it.  This will only work if you can launch your Java applet or
whatever by dragging it onto MRJ, and you need Mac::AppleEvents::Simple,
which I posted to the list a few days ago (or you can roll your own Apple
Events).

1.  Make copies of the app for each instance you want (using File::Copy)
2.  Launch each copy, not with Mac::Apps::Launch, which takes a creator ID,
but with AppleEvents that basically open the copy with a given applet (in
this case, HTML files):

#!perl -wl
use strict;
use Mac::AppleEvents::Simple;
use Mac::MoreFiles;  # for %Application
use File::Basename;
use File::Copy;

my $java = $Application{WARZ};  # location of MRJ
my $dir = dirname($java);       # base directory
my @apps = map {"$dir:Applets:$_:example1.html"}
           qw/Animator ArcTest BarChart/;         # example files

my $x = 0;
my %app;
foreach (@apps) {
  ++$x;
  copy($java, "$java.$x");   # copy MRJ
  $app{"$java.$x"} = $_;     # assign each copy with an applet
}

my $obj = 'obj{want:type(cobj), from:null(), ' .
  'form:enum(name), seld:TEXT(@)}';                # AE object stuff

foreach (keys %app) {
  my @ae = ("'----':$obj, usin:$obj", $app{$_}, $_);  # set parameters
  my $evt = do_event(qw/aevt odoc MACS/, @ae) or die $^E;  # launch
#  print $evt->{EVENT};  # troubleshoot
#  print $evt->{REPLY};  # troubleshoot
}

__END__

You would likely have to manually delete each copy of MRJ when finished.

Hope this helps,

--
Chris Nandor          mailto:pudge@pobox.com         http://pudge.net/
MacPerl: Power and Ease (ISBN 1881957322), http://www.ptf.com/macperl/
%PGPKey = ('B76E72AD', [1024, '0824090B CE73CA10  1FF77F13 8180B6B6'])



***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch