Menu

Compiling multiple java files and jar files

cache
2014-04-03
2014-04-21
  • cache

    cache - 2014-04-03

    Hey ,
    I am working on a project that involves porting a java program on arduino. The problem is that I am new to all of this. So i have a question. Is it possible to compile more than one java program on HaikuVM and upload the hex to arduino ? Also i was thinking is it possible to compile .jar files using Haiku ? Any help / suggestions would be appreciated.

    Thanks in advance
    Cache

     
    • genom2

      genom2 - 2014-04-03

      Compiling more than one Java program into one (third) program is not a question of HaikuVM but of Java programming. Consider this:

      public class Program1 {
          public static void main(String[] args) {
              System.out.println("Hello ");
          }
      }
      

      and this:

      public class Program2 {
          public static void main(String[] args) {
              System.out.println("World!");
          }
      }
      

      Both can be called from within this:

      public class Program3 {
          public static void main(String[] args) {
              Program1.main(null);
              Program2.main(null);
          }
      }
      

      Hope this is of some help.

      Kind regards
      Bob Genom

       
  • cache

    cache - 2014-04-08

    Hey Bob ,
    Thanks for the info !! My other quesstion is how to compile a java fn which calls a .jar file in haiku. Will the compiler be able to also compile the .jar file and convert it into .hex file for me to upload into Arduino ? Please do enlighten me ! Also please tell me if I am not clear with my question !

     
    • genom2

      genom2 - 2014-04-12

      Hello Cache,

      I found a non elegant solution to include a JAR file. This is how it works:
      1) put your JAR file (let's call it 'mylib.jar') into ./lib/nxt.
      2) Patch file ./bin/makeclasses.mk from:
      ...main\java;$(NXJ_HOME)\lib\nxt\classes.jar;$(NXJ_HOME)\bootstrap\src...
      into
      ...main\java;$(NXJ_HOME)\lib\nxt\classes.jar;$(NXJ_HOME)\lib\nxt\mylib.jar;$(NXJ_HOME)\bootstrap\src...

      As said, it's not elegant (but it works). So I will offer a more elegant solution in the next release of HaikuVM, comming soon.

      I hope this is of some (intermediate) help.

      Kind regards
      Bob Genom

       
      • cache

        cache - 2014-04-21

        Hello Bob ,
        Thank you for taking time and helping me sort the issue with this workaround. I have not yet tried this. I will try it and tell you how it goes. definitely this is of great help to me !!

        Thanks
        Cache

         

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.