/** * Gets the application's home directory as set by the system property "${ceres.context}.home". * If not set, the method determines the home directory by retrieving the URL of this * class using the method {@link #getApplicationHomeDir(java.net.URL)}. * * @return an assumption of an application's home directory, never <code>null</code> */ public static File getApplicationHomeDir() { final String homeKey = getApplicationHomePropertyName(); final String homeValue = System.getProperty(homeKey); if (homeValue != null) { return new File(homeValue); } // Use fallback final URL url = SystemUtils.class.getResource(getClassFileName(SystemUtils.class)); return getApplicationHomeDir(url); }
final URL url = SystemUtils.class.getResource(getClassFileName(SystemUtils.class)); String path = url.getPath(); try {
@Test public void testClassFileName() { assertEquals("Date.class", SystemUtils.getClassFileName(java.util.Date.class)); assertEquals("InputStream.class", SystemUtils.getClassFileName(java.io.InputStream.class)); assertEquals("SystemUtils.class", SystemUtils.getClassFileName(SystemUtils.class)); final URL url = SystemUtils.class.getResource(SystemUtils.getClassFileName(SystemUtils.class)); assertNotNull(url); assertTrue("url = " + url.getPath(), url.getPath().endsWith("/org/esa/beam/util/SystemUtils.class")); }