public class ApplicationClasspath extends Object
Modifier and Type | Field and Description |
---|---|
static int |
FIND_FROM_CLASSPATH |
static int |
FIND_FROM_THIS |
Constructor and Description |
---|
ApplicationClasspath() |
Modifier and Type | Method and Description |
---|---|
static void |
add(File file)
Adds a file (absolute path) to the classpath.
|
static void |
add(String filename)
Adds a filename (absolute path) to the classpath.
|
static void |
add(URL url)
Adds an URL (absolute path) to the classpath.
|
static void |
addJars(File dir)
Adds all jar files in a directory (absolute path) to the classpath.
|
static void |
addJars(String dirName)
Adds all jar files in a directory (absolute path) to the classpath.
|
static void |
addJarsRelative(File dir)
Adds all jar files in a directory to the classpath.
|
static void |
addJarsRelative(String dirName)
Adds all jar files in a directory to the classpath.
|
static void |
addRelative(File relativeFile)
Adds a relative file to the classpath.
|
static void |
addRelative(String relativeFilename)
Adds a relative filename to the classpath.
|
static File |
getAppBaseDir()
Returns the basedir of the application using the default method
|
static File |
getAppBaseDir(int basedirMethod)
Returns the basedir of the application using the supplied method constant
|
static File |
getAppBaseDirFromClasspath()
Returns the parent of the first part of the applications classpath which
is usually the directory containing the main jar file of the application.
|
static File |
getAppBaseDirFromThis()
Returns the basedir where this class is located.
|
static void |
setDefaultBasedirMethod(int newDefaultBasedirMethod)
Sets the default method witch is used by getAppBaseDir()
|
public static final int FIND_FROM_CLASSPATH
public static final int FIND_FROM_THIS
public static void add(String filename) throws IOException
filename
- name of absolute path to (jar)file or dirIOException
public static void add(File file) throws IOException
file
- absolute path to (jar)file or dirIOException
public static void add(URL url) throws IOException
url
- absolute path to (jar)file or dir as URLIOException
public static void addRelative(String relativeFilename) throws IOException, URISyntaxException
relativeFilename
- name of (jar)file or dir relative to
getAppBaseDir()IOException
URISyntaxException
public static void addRelative(File relativeFile) throws IOException, URISyntaxException
relativeFile
- (jar)file or dir relative to getAppBaseDir()IOException
URISyntaxException
public static void addJars(String dirName) throws IOException
dirName
- absolute path to directoryIOException
public static void addJars(File dir) throws IOException, FileNotFoundException
dir
- absolute path to directoryIOException,
- FileNotFoundExceptionIOException
FileNotFoundException
public static void addJarsRelative(String dirName) throws IOException, URISyntaxException
dirName
- path as string to directory relative to getAppBaseDir()IOException,
- URISyntaxExceptionIOException
URISyntaxException
public static void addJarsRelative(File dir) throws IOException, URISyntaxException
dir
- path to directory relative to getAppBaseDir()IOException,
- URISyntaxExceptionIOException
URISyntaxException
public static File getAppBaseDir() throws URISyntaxException
URISyntaxException
getAppBaseDirFromThis()
,
getAppBaseDirFromClasspath()
public static File getAppBaseDir(int basedirMethod) throws URISyntaxException
URISyntaxException
getAppBaseDirFromThis()
,
getAppBaseDirFromClasspath()
public static void setDefaultBasedirMethod(int newDefaultBasedirMethod)
newDefaultBasedirMethod
- constant f.e. this.FIND_FROM_THISpublic static File getAppBaseDirFromThis() throws URISyntaxException
URISyntaxException
public static File getAppBaseDirFromClasspath() throws URISyntaxException
URISyntaxException
Copyright © 2012–2018 Cenote GmbH. All rights reserved.