• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Using Java and Objective-C from same app
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Using Java and Objective-C from same app


  • Subject: Re: Using Java and Objective-C from same app
  • From: Marc Pergand <email@hidden>
  • Date: Wed, 18 Feb 2004 11:23:38 +0100

You can load, from ObjectiveC, any Java class and instantiate it:

NSJavaSetupVirtualMachine();
Class javaClass = NSClassFromString(@"MyJavaClass");
[[javaClass alloc]init];

see http://cocoadevcentral.com/articles/000024.php for more details.

The reverse operation is more complicated, you can't load an ObjectiveC class from Java, you need to deal with stubs files and the bridget app, see http://developer.apple.com/documentation/LegacyTechnologies/WebObjects/ WebObjects_3.1/Java/WrappingObjectiveC.html#REF13362

I tried this for a while with no success(obsolete?).

The only workaround is to use sendActionToTargetFromSender (NSApplication), it allows you to call any Java or ObjectiveC class method, see http://perso.wanadoo.fr/mpergand/tutoriels/divers_exemples/en/ DoItOnMainThread.dmg as an example.

This problem has been discussed many times on this list, do some searching with 'java bridge' keywords.

Marc.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Prev by Date: How to obtain correct AudioDevice playback time information?
  • Next by Date: Re: Drawing shadows under views
  • Previous by thread: Using Java and Objective-C from same app
  • Next by thread: Used Size of Text View
  • Index(es):
    • Date
    • Thread