It's only visible to the same class loader as the one which loaded the class. However, the visibility of the properties file depends then on the class loader in question. InputStream input = classLoader.getResourceAsStream("/com/example/foo.properties") ClassLoader classLoader = getClass().getClassLoader() Only when you're using a "relative" class loader such as (), then you indeed need to start it with a /. Note that this path of a context class loader should not start with a /. InputStream input = classLoader.getResourceAsStream("com/example/foo.properties") If you have placed the foo.properties it in a Java package structure like com.example, then you need to load it as below ClassLoader classLoader = Thread.currentThread().getContextClassLoader() In for example Tomcat you can configure it as shared.loader property of Tomcat/conf/catalina.properties. You can alternatively also put it somewhere outside the default classpath and add its path to the classpath of the appserver. If you're using a Maven project, drop it in /main/resources folder. If you're developing a standard WAR project in an IDE, drop it in src folder (the project's source folder). If the propertiesfile is webapp-specific, best is to place it in /WEB-INF/classes. webapp's /WEB-INF/lib and /WEB-INF/classes, server's /lib, or JDK/JRE's /lib. Here foo.properties is supposed to be placed in one of the roots which are covered by the default classpath of a webapp, e.g. Properties properties = new Properties() InputStream input = classLoader.getResourceAsStream("foo.properties") So that you can load it by ClassLoader#getResourceAsStream() with a classpath-relative path: ClassLoader classLoader = Thread.currentThread().getContextClassLoader()
There are basically three ways in a Java web application archive (WAR): Try again all the installation and remove the values inside the CLASSPATH variables or removes quotes inside.It's your choice. If you still do not have this message, you missed something! If not, restart your computer and try again the ant -v command. If you see this message above, Apache Ant is installed. In Variable value, enter: %JAVA_HOME%\bin %ANT_HOME%\bin %PATH% Ĭlick OK to close this window and OK to close the System Properties one as well.Īpache Ant(TM) version 1.8.2 compiled on December 20 2010
In Variable value, enter: C:\soft\java\jdk1.7.0 In Variable value, enter: C:\soft\apache\ant-1.8.2 In the User variables for YOURNAME, click New. The Environment Variables window appears. This is the System Properties and the Advanced tab is already selected.Ĭlick Environment Variable. In the result, select: Edit the system environment variables Under All Programs, there is a search input. Now you have to set the environment variables correctly. So if you already installed it in a path like this: C:\Program Files (x86)\Java\jdk 1.7.0, you have to uninstall and reinstall it in a new directory with a path like that: C:\soft\java\jdk1.7.0 B.
Instead use this one: C:\soft\apache\ant-1.8.2īecause Ant does not accept spaces and quotes in its path.Īnd Windows will never find it when you will try to run it.
You must install Ant in a directory, and the path must not have any space inside.įor example: C:\Program Files (x86)\Apache Ant 1.8.2 is really bad! Two things are important, the path for the directory and the path for the environment variables.
So, we will install Ant on Windows and for that we will use in this tutorial: So, let's get started with this tutorial of Apache Ant on Windows operating system.
It can generates files and directory from simple XML files. Ant is a Java tool that can help you building projects and setting them correctly.