Cocoa classes -> Java?

  • I am researching using Java to write an application that will run on a
    variety of platforms including Mac OS X and various Unix/Linux
    configurations.

    My question is:

    Is there a way to create a system menu item (NSStatusItem), preference pane
    and contextual menu using Java instead of Cocoa for Mac OS X?

    I cannot seem to find anything, and Java being interpreted seems to imply
    that placing some kind of Java class in the /Library/PreferencesPane
    directory wont work.

    Anyone had any luck? Is it documented as possible/not possible?
  • On Jan 14, 2008, at 9:29 AM, Patrick M wrote:

    > Is there a way to create a system menu item (NSStatusItem),
    > preference pane
    > and contextual menu using Java instead of Cocoa for Mac OS X?

    Not really. NSStatusItem might be present in the Java bindings, I'm
    not sure, but I do know they are deprecated and have been for some
    time now. CM plugins must have at least their base code written in C.

    Nick Zitzmann
    <http://www.chronosnet.com/>
  • On Jan 14, 2008, at 8:29 AM, Patrick M wrote:

    > Is there a way to create a system menu item (NSStatusItem),
    > preference pane
    > and contextual menu using Java instead of Cocoa for Mac OS X?
    >
    > I cannot seem to find anything, and Java being interpreted seems to
    > imply
    > that placing some kind of Java class in the /Library/PreferencesPane
    > directory wont work.
    >
    > Anyone had any luck? Is it documented as possible/not possible?

    The System Preferences preference pane API and NSStatusItem API are
    Cocoa-based APIs, so by definition you must use Cocoa to write code
    against them.  Finder contextual menu item plug-ins currently use a
    CFPlugIn-based API, not a Cocoa API.

    Whether you use Objective-C is orthogonal from whether you use Cocoa,
    though Objective-C is the native language of the Cocoa frameworks.

      -- Chris
  • I assume there is a way to call Java from Cocoa? something like JNI for
    Cocoa?

    On Jan 14, 2008 1:43 PM, Chris Hanson <cmh...> wrote:

    > On Jan 14, 2008, at 8:29 AM, Patrick M wrote:
    >
    >> Is there a way to create a system menu item (NSStatusItem),
    >> preference pane
    >> and contextual menu using Java instead of Cocoa for Mac OS X?
    >>
    >> I cannot seem to find anything, and Java being interpreted seems to
    >> imply
    >> that placing some kind of Java class in the /Library/PreferencesPane
    >> directory wont work.
    >>
    >> Anyone had any luck? Is it documented as possible/not possible?
    >
    > The System Preferences preference pane API and NSStatusItem API are
    > Cocoa-based APIs, so by definition you must use Cocoa to write code
    > against them.  Finder contextual menu item plug-ins currently use a
    > CFPlugIn-based API, not a Cocoa API.
    >
    > Whether you use Objective-C is orthogonal from whether you use Cocoa,
    > though Objective-C is the native language of the Cocoa frameworks.
    >
    > -- Chris
    >
    >
  • On Jan 14, 2008, at 17:29, Patrick M wrote:

    > I am researching using Java to write an application that will run on a
    > variety of platforms including Mac OS X and various Unix/Linux
    > configurations.
    >
    > My question is:
    >
    > Is there a way to create a system menu item (NSStatusItem),
    > preference pane
    > and contextual menu using Java instead of Cocoa for Mac OS X?

    Not any more. Until Tiger, Apple supported writing Cocoa applications
    in Java, but this was removed, probably due to lack of interest of
    both Apple and the developers.
    Now you have to use JNI as the interface, optionally writing your own
    Java Bridge (make sure you publish it if you do that!).

    andy
  • On 14 Jan 2008, at 16:29, Patrick M wrote:

    > I am researching using Java to write an application that will run on a
    > variety of platforms including Mac OS X and various Unix/Linux
    > configurations.
    >
    > My question is:
    >
    > Is there a way to create a system menu item (NSStatusItem),
    > preference pane
    > and contextual menu using Java instead of Cocoa for Mac OS X?
    >
    > I cannot seem to find anything, and Java being interpreted seems to
    > imply
    > that placing some kind of Java class in the /Library/PreferencesPane
    > directory wont work.
    >
    > Anyone had any luck? Is it documented as possible/not possible

    A slightly unrelated comment.  Mac users are often very particular
    about their UIs, and creating cross platform programs inevitably
    creates inconsistencies in the way the UI works, and the way the
    platform expects it to work.  Think carefully about whether you really
    want a cross platform app in it's truest sense, because often you will
    get 0 OS X customers if you don't do a real port.

    Bob

    p.s. There are many qualifications that need to be applied to this
    very general comment, for example, scientific apps usually have users
    that don't care what it looks/feels like, but just care about the
    feature set.
  • On Jan 14, 2008, at 4:57 PM, Andreas Monitzer wrote:
    > On Jan 14, 2008, at 17:29, Patrick M wrote:
    >> I am researching using Java to write an application that will run
    >> on a
    >> variety of platforms including Mac OS X and various Unix/Linux
    >> configurations.
    >>
    >> My question is:
    >>
    >> Is there a way to create a system menu item (NSStatusItem),
    >> preference pane
    >> and contextual menu using Java instead of Cocoa for Mac OS X?
    >
    > Not any more. Until Tiger, Apple supported writing Cocoa
    > applications in Java, but this was removed, probably due to lack of
    > interest of both Apple and the developers.
    > Now you have to use JNI as the interface, optionally writing your
    > own Java Bridge (make sure you publish it if you do that!).

    I don't think the Java bridge would necessarily have helped OP --
    sounded more like OP wanted a portable API.

    In any case, if you do want to go between Java and Objective-C, I
    would encourage you to have a poke at what the eclipse folks have been
    up to.  They have built a some new bridging stuff that was working
    quite well for them the last time I had a look (few months ago).

    b.bum
  • So as I understand it, with some additional research I have done:

    Pure Java *was* possible for NSStatusItem but the official Apple bridge is
    now deprecated, though this other bridge that someone mentioned might solve
    that problem.

    Is this also true for PrefPane? Is it possible to use a pure Java class to
    create a PrefPane bundle? I am just curious at this point, it would still be
    deprecated now, if it was ever possible.

    Platform independent Java components are not possible because the bridge is
    required to call the NSStatusItem API etc...

    Thanks for the info everyone.

    On Jan 15, 2008 1:19 AM, Art Taylor <art...> wrote:

    > You can still create NSStatusItems and manage PreferencePanes in
    > Java.  I just cracked open an old project I wrote in 2003 or so and
    > rebuilt it in XCode 3 and Leopard (targeted to 10.5, etc.).  Jikes
    > wouldn't build it but javac did just fine.
    >
    > The guts of the NSStatusItem creation amounted to this code, in a
    > method called from #awakeFromNib().
    >
    > NSStatusBar bar = NSStatusBar.systemStatusBar();
    > statusItem = bar.statusItem(-1F);
    > NSImage statusIcon = NSImage.imageNamed("statusItem");
    > statusIcon.setSize(new NSSize(16.0f, 16.0f));
    > statusItem.setImage(statusIcon);
    > statusItem.setHighlightMode(true);
    > statusItem.setMenu(theMenu);
    > statusItem.setEnabled(true);
    >
    > I wrote it while bored, on the road, and in an hotel room so don't
    > criticize it so much in retrospect.
    >
    > -a.
    >
    > On Jan 14, 2008, at 8:29 AM, Patrick M wrote:
    >
    >> I am researching using Java to write an application that will run on a
    >> variety of platforms including Mac OS X and various Unix/Linux
    >> configurations.
    >>
    >> My question is:
    >>
    >> Is there a way to create a system menu item (NSStatusItem),
    >> preference pane
    >> and contextual menu using Java instead of Cocoa for Mac OS X?
    >>
    >> I cannot seem to find anything, and Java being interpreted seems to
    >> imply
    >> that placing some kind of Java class in the /Library/PreferencesPane
    >> directory wont work.
    >>
    >> Anyone had any luck? Is it documented as possible/not possible?
    >>
    >
    >
  • On Jan 15, 2008, at 16:09, Patrick M wrote:

    > Pure Java *was* possible for NSStatusItem but the official Apple
    > bridge is
    > now deprecated, though this other bridge that someone mentioned
    > might solve
    > that problem.

    Right now there is no other bridge, just JNI.

    > Is this also true for PrefPane? Is it possible to use a pure Java
    > class to
    > create a PrefPane bundle? I am just curious at this point, it would
    > still be
    > deprecated now, if it was ever possible.

    Yes, it was possible. In fact, the original System Preferences
    application and its panes were written in Java, and later ported to
    Objective C.
    The Java Bridge allowed seamlessly subclassing Objective C classes, it
    was very nice while it lasted.

    andy
previous month january 2008 next month
MTWTFSS
  1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31      
Go to today