1 Reply Latest reply: Aug 21, 2010 2:22 PM by jschellSomeoneStoleMyAlias RSS

    Compiling for system-specific libraries on multiple platforms?

    843810
      Hello,
      I have an interesting dilemma: I have inserted some code into a program that uses some some of the com.apple.eawt packages. I can run the compiled bytecode on any system, including Mac OS X, Ubuntu, and Windows, but I can only do the compiling from the Mac OS X platform because of the use of the com.apple.eawt packages. Is there some way I can make the source compilable on any platform, like a force option? I had thought of using reflection to use the packages, but that seems like a lot of code for such a simple task, plus I don't know if that will really work at all.

      Are there any suggestions?
      Thank You in advance.

      Edited by: Quytelda on Aug 13, 2010 9:42 PM
        • 1. Re: Compiling for system-specific libraries on multiple platforms?
          jschellSomeoneStoleMyAlias
          Quytelda wrote:
          Hello,
          I have an interesting dilemma: I have inserted some code into a program that uses some some of the com.apple.eawt packages. I can run the compiled bytecode on any system, including Mac OS X, Ubuntu, and Windows, but I can only do the compiling from the Mac OS X platform because of the use of the com.apple.eawt packages.
          As stated that is incorrect.

          If you are using package X (excluding reflection via strings) then during compilation and runtime package X must be available.

          Now perhaps one of the following is true.
          1. You are delivering those packages with your code.
          2. You have a runtime switch that skips that code when it doesn't exist.

          Is there some way I can make the source compilable on any platform, like a force option?
          Just what I said above....

          If you are using package X (excluding reflection via strings) then during compilation and runtime package X must be available.
          I had thought of using reflection to use the packages, but that seems like a lot of code for such a simple task, plus I don't know if that will really work at all.

          Are there any suggestions?
          Via reflection if you ONLY used string references to ALL the classes/methods then it will compile. So a line like the following will compile on any system.

          Class X = Class.forName("com.apple.eawt.X");

          In terms of compiling however, note that presumably unit tests exist and you would have the same problem with those as with the code.

          Depending on specifics of the application it might easier to do the following.
          1. Create a proxy class(es)
          2. Wrap the apple code as a separate deliverable - with its public API being the proxy.
          3. Build that deliverable and deliver it into the main project as a jar.

          The result of that is that the main deliverable will always build on any platform. The Apple deliverable would build only on Apple.