Hello

I'm trying to create a cross platform application to control a robot. Everything went relatively easy but I got stuck when trying to set a few properties that are Mac specific. They use the 'com.apple.eawt' package which obviously isn't available on Linux or Windows. I need to set the program to use the system menu bar and the dock icon and some handlers. I know how to do this but I don't know how to tell Linux to skip the part that is Mac specific.
I can check the operating system at runtime but the code won't compile on Linux because of that missing package.
When I add some Linux specific stuff (I develop on a Mac) the code won't compile on my Mac anymore.

I'm relatively new to Java but I know lots of other languages like C, C++, Ruby, Scheme,... I know how to do this in C/C++ but that won't work here.

Thanks!


Jasper

huuuh, so long ... with Mac, I think that's predinosaurus API, sure maybe I wrong, but depends == which instaled Mac OS version

if is possible, please todays java ATW(equivalent is WindowListener) + Swing coming from Java 1.6

I haven't played with that sort of problem before, but could you do something with inheritance? I'm thinking you'd have an abstract SystemPropsLoader, which would subclass a MacPropsLoader and a LinuxPropsLoader and an Atari2600PropsLoader and so forth for any system you wanted to work with.

Trouble is, as I think about this, if this is a compile-time problem then you're going to have to repackage for each platform, but maybe that's the way to do it.

Perhaps you could get around that problem, though, by making dummy packages for the com.apple stuff, so your Linux machine would find it... That way, you could include all of the classes, and just run the appropriate one for the system you're running on, since it wouldn't actually try to use com.apple.whosit unless it was actually running under MacOS.
I dunno, I'm just thinking aloud here. Hope it spurs some useful ideas.

I had also thought about the inheritance but it is a compile time problem so it wouldn't help. What I could do is create the dummy package but I would rather create a separate program for each platform than do such a 'dirty' trick.

Thanks for the reply

I haven't played with that sort of problem before, but could you do something with inheritance? I'm thinking you'd have an abstract SystemPropsLoader, which would subclass a MacPropsLoader and a LinuxPropsLoader and an Atari2600PropsLoader and so forth for any system you wanted to work with.

Trouble is, as I think about this, if this is a compile-time problem then you're going to have to repackage for each platform, but maybe that's the way to do it.

Perhaps you could get around that problem, though, by making dummy packages for the com.apple stuff, so your Linux machine would find it... I dunno, I'm just thinking aloud here. Hope it spurs some useful ideas.

Hm. I'm not sure writing your SystemLoader as an abstract class wouldn't help you, at least in so far as it would force you to put all of that functionality in one place. Compartmentalize the problem, it can't hurt.
I wonder if you might be able to use your build file for part of the solution. If you had "mac" and "linux" targets, at least you could tell it which version to try to compile...

It's a new problem for me, my friend. Wish I had better answers. Or any answers. :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.