Re: Java and C
Re: Java and C
- Subject: Re: Java and C
- From: Alykhan Jetha <email@hidden>
- Date: Wed, 29 Aug 2001 12:15:29 -0400
ObjC and Java can definitely be mixed in a Cocoa app, although
app launch times are considerably affected if you include Java.
You can message a Java object from Objc without much trouble at all:
// assuming class path is properly initialized and JVM is loaded
myJavaObject = [[NSClassFromString(@"your.nifty.java.class")
alloc] init];
anotherObject = [myJavaObject doSomethingWith:arg1 :arg2 :arg3];
[myJavaObject release];
// anotherObject is automatically released by the bridge if you
don't retain -- basically it works the same was as ObjC
retain/release/autorelease paradigm
You will need to create some stub headers to keep the compiler quiet.
To message custom objc objects from your app from the Java side
is a lot harder. You have to create wrappers for each object.
You can do it in the new PB, but it's not trivial.
./aj
On Wednesday, August 29, 2001, at 11:18 AM, John Balestrieri wrote:
I'm just getting started with Cocoa, and I like it a lot.
Coming from a background in REALbasic, I was very pleased to
immediately jump in and start working with Java. However, I've
recently been reading (on Omnigroup's cocoa list archives)
about the memory and performance hog the Java VM is.
I am thinking I can mix Java and ObjC in my project. I would
implement the core memory and processor classes in ObjC, and
create the higher level functionality in Java (for me, the
syntax is more intuitive, hence faster for me to program). I
could always port the Java to ObjC as I gain proficiency in
ObjC. My questions are these:
Is there any performance hit when switching from the Java VM to
native compiled code?
Are there any 'gotchas' to watch out for when working in Java
with classes that were created in Objective C? Vice versa?
Am I wrong all together to think that the languages can be
mixed as I've described?
Thanks,
John
_______________________________________________
cocoa-dev mailing list
email@hidden
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
References: | |
| >Java and C (From: John Balestrieri <email@hidden>) |