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: Double clickable script question[SOLUTION]



Thank you for your help with this.

My solution is now a 150K java application that resides in the same directory as the larger bundled application (3MB) and calls Runtime.exec() as originally suggested. The NSJavaVirtualMachine bug went away when I changed the NSJavaNeeded key to "NO" as suggested below. To get my app to run in its client mode, the String[] to pass to exec() only needs to be the full path name at runtime (see below) to the JavaApplicationStub and the option "-client" as in:

public void run_client_app() {

// NOTE: Need to change Info.plist NSJavaNeeded property to "NO" (XCode bug)


String appName = "RunClient.app";
String userDir = System.getProperty("user.dir");
String appDir = userDir.substring(1, userDir.lastIndexOf(appName));
String scriptpath = File.separator + appDir + "MyApp.app/Contents/MacOS/JavaApplicationStub";


// array of Strings with path to JavaApplicationStub and -client option
String cmdarray[] = new String[]{scriptpath, "-client"};
Process proc = null;

try {
proc = Runtime.getRuntime().exec(cmdarray);
proc.waitFor();
//System.out.println("Process exit code: " + proc.exitValue());
} catch (IOException e) {
JOptionPane.showMessageDialog(null,
"Could not find or open the client (1).",
"IO Error",
JOptionPane.ERROR_MESSAGE);
} catch (InterruptedException e) {
JOptionPane.showMessageDialog(null,
"Could not find or open the client (2).",
"Interrupted Error",
JOptionPane.ERROR_MESSAGE);
}
System.exit(0);
}


Thanks to all who helped. You code!

A/Prof David Darby
Em email@hidden


On 06/10/2004, at 6:25 AM, Greg Guerin wrote:

Doug Zwick <email@hidden> wrote:

-[NSJavaVirtualMachine initWithClassPath:] cannot instantiate a Java
virtual machine

my java app quits "unexpectedly" and yet Safari opens anyway!

I suspect something is fundamentally messed up in your XCode project. Try building and running a simple test case from the command line using javac and java, like this code put into file ExecTest.java:

I think the problem is an NSJavaNeeded key being set to YES in the
Info.plist. Change the setting to NO and the error message should go away.
Or remove the key entirely, though that might cause Xcode to helpfully add
it back, again set to YES.


If that's the problem, it's a long-standing problem in Xcode, and even in
PB, as I vaguely recall. Some templates are wrong, so please be sure to
file a bug-report.


-- 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
References: 
 >Re: Double clickable script question[Explanation of SOLUTION] (From: Greg Guerin <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.