Java Class Path getAppPath(Class clazz)

Here you can find the source of getAppPath(Class clazz)

Description

get App Path

License

Open Source License

Exception

Parameter Description
URISyntaxException an exception

Declaration

public static File getAppPath(Class clazz) throws URISyntaxException 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.io.File;

import java.net.URISyntaxException;

public class Main {
    /**/*from w  ww.java2  s . com*/
     * @return
     * @throws URISyntaxException
     */
    public static File getAppPath(Class clazz) throws URISyntaxException {
        File appPath = new File(clazz.getProtectionDomain().getCodeSource().getLocation().toURI().getPath());
        return appPath.isFile() ? appPath.getParentFile() : appPath;
    }
}

Related

  1. getAbsolutePath(Class theClass, String path)
  2. getAbsolutePath(final Class clazz, final String relative)
  3. getApplicationPath(Class cls)
  4. getClass(String parentPath, String className)
  5. getClassAbsolutePath(Class c)
  6. getClassBasePath(Class aClass)
  7. getClassFilePath(Class clazz)