Re: [SOLVED] Re: calling Java for ObjC
Re: [SOLVED] Re: calling Java for ObjC
- Subject: Re: [SOLVED] Re: calling Java for ObjC
- From: Byron Wright <email@hidden>
- Date: Thu, 6 Jan 2005 10:46:58 -0800
Nothing changed that i am aware of. I added this to my info.plist in my
native target. If I am not mistaken (I'm sure someone will correct me
if I'm wrong) but when a JVM instance is created this is one of the
locations it looks for the NSJavaConfiguration. However, I get the
following warning messages when instantiating a JVM. I am using XCode
1.5 on Panther. Anyone know what they mean?
Java HotSpot(TM) Client VM warning: Attempt to protect stack guard
pages failed.
Java HotSpot(TM) Client VM warning: Attempt to deallocate stack guard
pages failed.
This is the results I get using Java Apache Soap and Googles Soap API,
which shows that all this is working :
2005-01-06 10:28:51.403 TechDemo[1637] googleSearch =
com.google.soap.search.GoogleSearch@7bd9f2
2005-01-06 10:28:55.852 TechDemo[1637] results = {
TM = 0.039625
Q = "apple"
CT = ""
TT = ""
CATs =
{
{SE="", FVN="Top/Computers/Companies/Product_Support/Apple"},
{SE="", FVN="Top/Computers/Systems/Apple"}
}
Start Index = 1
End Index = 10
Estimated Total Results Number = 16400000
Document Filtering = true
Estimate Correct = false
Rs =
{
[
URL = "http://www.apple.com/"
Title = "<b>Apple</b>"
Snippet = "<b>...</b> Visit the <b>Apple</b> Store online or at
retail locations. 1-800-MY-<b>APPLE</b>. Find Job<br> Opportunities at
<b>Apple</b>. <b>...</b> Copyright © 2005 <b>Apple</b> Computer, Inc.
<b>...</b> "
Directory Category = {SE="",
FVN="Top/Computers/Systems/Apple/Macintosh"}
Directory Title = "<b>Apple</b> Computer, Inc."
Summary = "<b>Apple's</b> main homepage."
Cached Size = "17k"
Related information present = true
Host Name = ""
],........... blah blah blah 9 more results
btw, this is all the Objective-C test code I had to write to get
searching google working, pretty neat stuff (the objc-java-bridge).
Nice to see two of my favorite technologies work so well together.
- (id) init
{
if(self = [super init])
{
NSString * cp = [NSString
stringWithFormat:@"%@:%@",[NSJavaVirtualMachine
defaultClassPath],@"./googleapi.jar"];
jvm = [[NSJavaVirtualMachine alloc] initWithClassPath:cp];
googleSearch =
[[NSClassFromString(@"com.google.soap.search.GoogleSearch") alloc]
init];
NSLog(@"googleSearch = %@",googleSearch);
[googleSearch setKey:GOOGLE_KEY];
[self searchFor:@"apple"];
}
return self;
}
- (void) searchFor : (NSString * ) query
{
[googleSearch setQueryString: query];
id results = [googleSearch doSearch];
NSLog(@"results = %@",results);
}
On Jan 5, 2005, at 11:54 PM, Evan Schoenberg wrote:
Hm, glad that worked for you. I tried the same and couldn't get the
JavaVM to ever load the newer version; the documentation seems to
indicate that these keys exist for double-clickable wrapped .jar
files, not for the framework. So what changed between it not working
and it now working?
-Evan
On Jan 5, 2005, at 10:40 PM, Byron Wright wrote:
Odd,
adding this in the info.plist now works, (it didn't work before
uneven after a clean rebuild).
<key>Java</key>
<dict>
<key>JVMVersion</key>
<string>1.4*</string>
</dict>
-Byron
Evan, my class was getting instantiated, i checked in the debugger.
As soon as my custom class attempted to call the apache soap API
which in turn instantiates an XML parsed it would fail, the stack
trace from the VM verifies that.
On Jan 5, 2005, at 8:32 PM, Evan Schoenberg wrote:
Are you sure
testSoap = [NSClassFromString(@"TestWeatherSoap") new];
is actually working? Try NSLog(@"testSoap: %@",testSoap); and see
what it's doing.
(Unsupported major.minor version 48.0)
This is quite likely (based on my experience) because the java class
you're loading requires Java 1.4.x. JavaVM.framework loads Java
1.3.1. I spent a -long- time trying to figure out how to get it
load Java 1.4.x to no avail... if you manage to get around this,
-please- post it to the list.
Hope that helps,
Evan
On Jan 5, 2005, at 8:23 PM, Byron Wright wrote:
I am attempting to instantiate and call Java classes from
Objective-C and I am running into the following error after
instantiating a Java class and when calling it's methods on Panther
:
2005-01-05 17:59:37.606 TechDemo[1297] An uncaught exception was
raised
2005-01-05 17:59:37.646 TechDemo[1297]
java/lang/UnsupportedClassVersionError: org/w3c/dom/Node
(Unsupported major.minor version 48.0)
Stack Trace:
java.lang.UnsupportedClassVersionError: org/w3c/dom/Node
(Unsupported major.minor version 48.0)
at java.lang.ClassLoader.defineClass0(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:488)
at
java.security.SecureClassLoader.defineClass(SecureClassLoader.java:
106)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:243)
at java.net.URLClassLoader.access$100(URLClassLoader.java:51)
at java.net.URLClassLoader$1.run(URLClassLoader.java:190)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:183)
at java.lang.ClassLoader.loadClass(ClassLoader.java:294)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:288)
at java.lang.ClassLoader.loadClass(ClassLoader.java:250)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:310)
at TestWeatherSoap.getTemp(TestWeatherSoap.java:22)
at TestWeatherSoap.test(TestWeatherSoap.java:61)
2005-01-05 17:59:37.646 TechDemo[1297] *** Uncaught exception:
<java/lang/UnsupportedClassVersionError> org/w3c/dom/Node
(Unsupported major.minor version 48.0)
The following code generates the error:
- (id) init
{
if(self = [super init])
{
NSString * cp = [NSString
stringWithFormat:@"%@:%@",[NSJavaVirtualMachine
defaultClassPath],@"./soap.jar:./SoapTest.jar"]; //add apache soap
and my custom classes to classpath
NSLog(@"classpath = %@",cp);
jvm = [[NSJavaVirtualMachine alloc] initWithClassPath:cp];
testSoap = [NSClassFromString(@"TestWeatherSoap") new]; //works
fine
[self searchFor:@"98125"];
}
return self;
}
- (void) searchFor : (NSString * ) query
{
[testSoap test]; //causes error
}
The resources I have been able to find using google suggest that
the wrong version of the JVM is being instantiated. I found this
info here : http://www.cocoadev.com/index.pl?XcodeObjCJavaBridge
One possible solution and according to Apple's documentation
(http://developer.apple.com/documentation/Java/Conceptual/
Java141Development/index.html ) I should be able to add the
following to the info.plist file. However, this doesn't seem to
work. There doesn't seem to be much documentation on Apple's site
about NSJavaVirtualMachine and by looking at the header file I
don't see any may of specifying this when creating an instance of
the JVM.
- Byron
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
email@hidden
This email sent to email@hidden
Byron Wright
Software Developer
Siemens Business Services Media
(formerly BBC Technology)
Mobile: 206-227-4645
Email: email@hidden
www.bbctechnology.com
www.siemens.co.uk/sbs
This e-mail (and any attachments) contains confidential information
and is for the exclusive use of the addressee/s. Any views contained
in this e-mail are not the views of Siemens Business Services Media
Holdings Ltd unless specifically stated. If you are not the
addressee, then any distribution, copying or use of this e-mail is
prohibited. If received in error, please advise the sender and
delete/destroy it immediately. We accept no liability for any loss or
damage suffered by any person arising from use of this e-mail/fax.
Please note that Siemens Business Services Media Holdings Ltd
monitors e-mails sent or received. Further communication will signify
your consent to this.
Siemens Business Services Media Holdings Ltd
Registered No: 04128934 England
Registered Office: Siemens House, Oldbury, Bracknell, Berkshire, RG12
8FZ
Byron Wright
Software Developer
Siemens Business Services Media
(formerly BBC Technology)
Mobile: 206-227-4645
Email: email@hidden
www.bbctechnology.com
www.siemens.co.uk/sbs
This e-mail (and any attachments) contains confidential information and
is for the exclusive use of the addressee/s. Any views contained in
this e-mail are not the views of Siemens Business Services Media
Holdings Ltd unless specifically stated. If you are not the addressee,
then any distribution, copying or use of this e-mail is prohibited. If
received in error, please advise the sender and delete/destroy it
immediately. We accept no liability for any loss or damage suffered by
any person arising from use of this e-mail/fax. Please note that
Siemens Business Services Media Holdings Ltd monitors e-mails sent or
received. Further communication will signify your consent to this.
Siemens Business Services Media Holdings Ltd
Registered No: 04128934 England
Registered Office: Siemens House, Oldbury, Bracknell, Berkshire, RG12
8FZ
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden