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

Revision 7751, 4.1 KB checked in by hinerm, 8 years ago (diff)

Modified javaTools library for Windows functionality

JTools was previously dependent on dirent.h, which is a POSIX library
dirent functionality was thus captured in conditional preprocessor macro code,
to be used on a windows system.
dirent.h is still included on Mac/Linux

Line 
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>
42#include <vector>
43#include <dirent.h>
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
51#ifdef WIN32
52  #ifndef MYAPI_API
53    #define MYAPI_API __declspec(dllexport)
54  #endif
55#else
56  #ifndef MYAPI_API
57    #define MYAPI_API
58  #endif
59#endif
60
61using namespace std;
62
63/**
64 * JavaTools provides static helper methods used in more than one
65 * of the various BFITK plugin implementations.
66 */
67class MYAPI_API JavaTools
68{
69  public:
70    typedef JavaTools      Self;
71
72    /**
73     * This method is used to instantiate a JVM with the following defaults:
74     * jarFolder: jar
75     * memory: 256MB
76     * headless: true
77     * extraJavaLibraryPath: current working directory
78     * extraClasspath: none
79     */
80    static void createJVM();
81
82    /**
83     * This method is used to instantiate a JVM with a custom class path.
84     */
85    static void createJVM(string jarFolder);
86
87    /**
88     * This method is used to instantiate a JVM with custom memory specifications.
89     */
90    static void createJVM(bool headless);
91
92    /**
93     * This method is used to instantiate a JVM with specified headless mode.
94     */
95    static void createJVM(int memory);
96
97    /**
98     * This method is used to instantiate a JVM with a custom class path and
99     * memory specifications..
100     */
101    static void createJVM(bool headless, int memory);
102
103    /**
104     * This method is used to instantiate a JVM with a custom class path and
105     * specified headless mode.
106     */
107    static void createJVM(string jarFolder, bool headless, int memory);
108
109    /**
110     * This method is the fundamental JVM creation method.
111     * classdir - specifies location of the core jar files, and extra jars (if present)
112     * jarlist - a ; separated list of additional jars to include in the JVM classpath.
113     *           jace-runtime.jar, loci_tools.jar and bio-formats.jar are always included.
114     * headless - whether to run headless or not
115     * memory - how much memory to instantiate the JVM with
116     */
117    static void createJVM(string jarFolder, bool headless, int memory, vector<string> extraClasspath, vector<string> extraJavaLibraryPath, vector<string> extraOptions);
118};
Note: See TracBrowser for help on using the repository browser.