Menu

Creating a java project with multiple files

2015-06-08
2015-06-11
  • Chinmay Nagarkar

    I'm unable to get haiku.bat to do the right thing when my java project has multiple files. My project looks like this:
    src
    - com
    ---- pp
    ------ Blink.java
    ------ Wire.java

    Blink.java has hte loop and setup methods and also references methods in Wire.java. If I remove Wire .java (and references to it) and run the following command, everything works great (all code is generated, no errors):
    D:\software\haikuvm132\bin\haiku.bat -v --Config arduinoIDE F:\workspace\adxl35\src\com\pp\Blink.java

    If I have Wire.java and references to it, and run the above command, the compilation step fails since the Wire.java is not passed to javac. I won't post the full trace here, but here's one of the errors:

    symbol: variable Wire
    location: class Blink
    F:\workspace\adxl35\src\com\pp\Blink.java:98: error: cannot find symbol
    Wire.endTransmission(); // false / don't release device /
    ^

    What switches do I need to use on the haiku.bat command for it to do the right thing? I'm using the latest release (1.3.2)

    Thanks!

     
    • genom2

      genom2 - 2015-06-08

      Supporting multiple Java files is really no problem for HaikuVM (to be precise: is no problem for javac).

      In your case, all you have to do is, set the classpath (which is passed to javac) to your project source like this:

      D:\software\haikuvm132\bin\haiku.bat -v --Config arduinoIDE --classpath F:\workspace\adxl35\src F:\workspace\adxl35\src\com\pp\Blink.java
      

      But, I do have to admit that my documentation is not very explicit on this. (Just a small hint in my FAQs: "Q: Is it possible to compile against a JAR library with HaikuVM?")

      The default classpath of HaikuVM is (as defined in './bin/makeclasses.mk'):

      HAIKU_HOME\haikuRT\src\main\java;HAIKU_HOME\bootstrap\src\main\java;HAIKU_HOME\examples\src\main\java;HAIKU_HOME\haikuBench\src\main\java;HAIKU_HOME\gallerie\src\main\java;HAIKU_HOME\incubator\src\main\java
      

      You may prepend to this default classpath with your <javaclasspath> given with the option --classpath <javaclasspath>.

      Thank you for your feedback. I will improve the documentation soon.

      BTW, did you try 'arduinoIDEUpload' instead of 'arduinoIDE'?

       

      Last edit: genom2 2015-06-08
  • Chinmay Nagarkar

    Thanks, Bob. I'll try this.

    Yes, I did try arduinoIDEUpload, and got an error. The error is very cryptic. I'll start a separate post to discuss that so we keep this post clean.

    Thanks again!

     
  • Chinmay Nagarkar

    Another solution is to escape the quotes on the command line. So, for instance,

    D:\software\haikuvm132\bin\haiku.bat -v --Config arduinoIDE --classpath "F:\runtime-EclipseApplication\asdf\lib\myLib.jar;F:\runtime-EclipseApplication\asdf\bin;" F:\runtime-EclipseApplication(1)\asdf\src\asdf\trial.java

    , do this:
    D:\software\haikuvm132\bin\haiku.bat -v --Config arduinoIDE --classpath \"F:\runtime-EclipseApplication\asdf\lib\myLib.jar;F:\runtime-EclipseApplication\asdf\bin;\" F:\runtime-EclipseApplication(1)\asdf\src\asdf\trial.java

    No batch file change required with this approach. Should be added to the documentation though.

     

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.