source: trunk/projects/jar2lib/src/main/resources/project-files/jtools/include/javaTools.h @ 7734

Revision 7734, 4.0 KB checked in by hinerm, 9 years ago (diff)

More control allowed in JavaTools

The following options were added to JavaTools:

  • specification of one folder containing jars to add to the classpath
  • specification of a list of files/directories to add to the classpath
  • specification of files to add to the java.library.path
  • specifications of commands to add as jace::CustomOptions

The header and method signature options were updated to reflect these changes
Note that with these changes the overall structure of jtools was simplified,
so a top-level directory from which other paths are relative can no longer be specified.

RevLine 
[7713]1//
2// javaTools.h
3//
4
5/*
6OME Bio-Formats ITK plugin for calling Bio-Formats from the Insight Toolkit.
7Copyright (c) 2008-@year@, UW-Madison LOCI.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12    * Redistributions of source code must retain the above copyright
13      notice, this list of conditions and the following disclaimer.
14    * Redistributions in binary form must reproduce the above copyright
15      notice, this list of conditions and the following disclaimer in the
16      documentation and/or other materials provided with the distribution.
17    * Neither the name of the UW-Madison LOCI nor the
18      names of its contributors may be used to endorse or promote products
19      derived from this software without specific prior written permission.
20
21THIS SOFTWARE IS PROVIDED BY UW-MADISON LOCI ''AS IS'' AND ANY
22EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
23WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24DISCLAIMED. IN NO EVENT SHALL UW-MADISON LOCI BE LIABLE FOR ANY
25DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
26(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
28ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31*/
32
33/*
34IMPORTANT NOTE: Although this software is distributed according to a
35"BSD-style" license, it requires the OME Bio-Formats Java library to do
36anything useful, which is licensed under the GPL v2 or later.
37As such, if you wish to distribute this software with Bio-Formats itself,
38your combined work must be distributed under the terms of the GPL.
39*/
40
41#include <string>
[7734]42#include <vector>
[7731]43#include <dirent.h>
[7713]44#include <iostream>
45#include "jace.h"
46#include "jace/JNIHelper.h"
47#include "jace/StaticVmLoader.h"
48#include "jace/JNIException.h"
49#include "jace/OptionList.h"
50
51using namespace std;
52
53/**
54 * JavaTools provides static helper methods used in more than one
55 * of the various BFITK plugin implementations.
56 */
57class JavaTools
58{
59  public:
60    typedef JavaTools      Self;
61
62    /**
63     * This method is used to instantiate a JVM with the following defaults:
[7734]64     * jarFolder: jar
[7713]65     * memory: 256MB
66     * headless: true
[7734]67     * extraJavaLibraryPath: current working directory
68     * extraClasspath: none
[7713]69     */
70    static void createJVM();
71
72    /**
73     * This method is used to instantiate a JVM with a custom class path.
74     */
[7734]75    static void createJVM(string jarFolder);
[7713]76
77    /**
78     * This method is used to instantiate a JVM with custom memory specifications.
79     */
[7734]80    static void createJVM(bool headless);
[7713]81
82    /**
83     * This method is used to instantiate a JVM with specified headless mode.
84     */
[7734]85    static void createJVM(int memory);
[7713]86
87    /**
88     * This method is used to instantiate a JVM with a custom class path and
89     * memory specifications..
90     */
[7734]91    static void createJVM(bool headless, int memory);
[7713]92
93    /**
94     * This method is used to instantiate a JVM with a custom class path and
95     * specified headless mode.
96     */
[7734]97    static void createJVM(string jarFolder, bool headless, int memory);
[7713]98
99    /**
100     * This method is the fundamental JVM creation method.
101     * classdir - specifies location of the core jar files, and extra jars (if present)
102     * jarlist - a ; separated list of additional jars to include in the JVM classpath.
103     *           jace-runtime.jar, loci_tools.jar and bio-formats.jar are always included.
104     * headless - whether to run headless or not
105     * memory - how much memory to instantiate the JVM with
106     */
[7734]107    static void createJVM(string jarFolder, bool headless, int memory, vector<string> extraClasspath, vector<string> extraJavaLibraryPath, vector<string> extraOptions);
[7713]108};
Note: See TracBrowser for help on using the repository browser.