processing.mode.java

## Class JavaBuild

- Object
- - JavaBuild

-     public class JavaBuild
      extends Object

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static String` | `PACKAGE_REGEX`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `JavaBuild(Sketch sketch)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `String` | `build(boolean sizeWarning)` Run the build inside a temporary build folder.
    `String` | `build(File srcFolder, File binFolder, boolean sizeWarning)` Preprocess and compile all the code for this sketch.
    `File` | `getBinFolder()`
    `String` | `getClassPath()` Class path determined during build.
    `boolean` | `getFoundMain()` Whether the preprocessor found a main() method.
    `ArrayList<Library>` | `getImportedLibraries()` Get the list of imported libraries.
    `String` | `getJavaLibraryPath()` Return the java.library.path for this sketch (for all the native DLLs etc).
    `String` | `getSketchClassName()`
    `String` | `getSketchPath()` Absolute path to the sketch folder.
    `File` | `getSrcFolder()` Path to the folder that will contain processed .java source files.
    `SketchException` | `placeException(String message, String dotJavaFilename, int dotJavaLine)` Map an error from a set of processed .java files back to its location in the actual sketch.
    `String` | `preprocess(File srcFolder, boolean sizeWarning)` Build all the code for this sketch.
    `String` | `preprocess(File srcFolder, String packageName, PdePreprocessor preprocessor, boolean sizeWarning)`

    - ### Methods inherited from class Object

      `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### PACKAGE_REGEX

          public static final String PACKAGE_REGEX

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### JavaBuild

          public JavaBuild(Sketch sketch)

  - ### Method Detail

    - #### build

          public String build(boolean sizeWarning)
                       throws SketchException

      Run the build inside a temporary build folder. Used for run/present.
      Returns:
        null if compilation failed, main class name if not
      Throws:
        `RunnerException`
        `SketchException`

    - #### build

          public String build(File srcFolder,
                     File binFolder,
                     boolean sizeWarning)
                       throws SketchException

      Preprocess and compile all the code for this sketch. In an advanced program, the returned class name could be different, which is why the className is set based on the return value. A compilation error will burp up a RunnerException.
      Returns:
        null if compilation failed, main class name if not
      Throws:
        `SketchException`

    - #### getSketchClassName

          public String getSketchClassName()

    - #### preprocess

          public String preprocess(File srcFolder,
                          boolean sizeWarning)
                            throws SketchException

      Build all the code for this sketch. In an advanced program, the returned class name could be different, which is why the className is set based on the return value. A compilation error will burp up a RunnerException. Setting purty to 'true' will cause exception line numbers to be incorrect. Unless you know the code compiles, you should first run the preprocessor with purty set to false to make sure there are no errors, then once successful, re-export with purty set to true.
      Parameters:
        `buildPath` - Location to copy all the .java files
      Returns:
        null if compilation failed, main class name if not
      Throws:
        `SketchException`

    - #### preprocess

          public String preprocess(File srcFolder,
                          String packageName,
                          PdePreprocessor preprocessor,
                          boolean sizeWarning)
                            throws SketchException

      Parameters:
        `srcFolder` - location where the .java source files will be placed
        `packageName` - null, or the package name that should be used as default
        `preprocessor` - the preprocessor object ready to do the work
      Returns:
        main PApplet class name found during preprocess, or null if error
      Throws:
        `SketchException`

    - #### getSrcFolder

          public File getSrcFolder()

      Path to the folder that will contain processed .java source files. Not the location for .pde files, since that can be obtained from the sketch.

    - #### getBinFolder

          public File getBinFolder()

    - #### getSketchPath

          public String getSketchPath()

      Absolute path to the sketch folder. Used to set the working directry of the sketch when running, i.e. so that saveFrame() goes to the right location when running from the PDE, instead of the same folder as the Processing.exe or the root of the user's home dir.

    - #### getClassPath

          public String getClassPath()

      Class path determined during build.

    - #### getJavaLibraryPath

          public String getJavaLibraryPath()

      Return the java.library.path for this sketch (for all the native DLLs etc).

    - #### getFoundMain

          public boolean getFoundMain()

      Whether the preprocessor found a main() method. If main() is found, then it will be used to launch the sketch instead of PApplet.main().

    - #### getImportedLibraries

          public ArrayList<Library> getImportedLibraries()

      Get the list of imported libraries. Used by external tools like Android mode.
      Returns:
        list of library folders connected to this sketch.

    - #### placeException

          public SketchException placeException(String message,
                                       String dotJavaFilename,
                                       int dotJavaLine)

      Map an error from a set of processed .java files back to its location in the actual sketch.
      Parameters:
        `message` - The error message.
        `filename` - The .java file where the exception was found.
        `line` - Line number of the .java file for the exception (0-indexed!)
      Returns:
        A RunnerException to be sent to the editor, or null if it wasn't possible to place the exception to the sketch code.