classpath

How to set the classpath in Java?

狂风中的少年 提交于 2019-12-01 10:42:55
问题 I've many jar files to add to my classpath, so everytime I compile my java file I end up with a command like this: javac -cp commons-digester-2.1/commons-digester-2.1.jar:lucene-core-3.0.3.jar:commons-logging-1.1.1/commons-logging-1.1.1.jar:commons-beanutils-core-1.7.0.jar:. CollectionIndexer.java I've tried to use: set CLASSPATH=commons-digester-2.1/commons-digester-2.1.jar:lucene-core-3.0.3.jar:commons-logging-1.1.1/commons-logging-1.1.1.jar:commons-beanutils-core-1.7.0.jar:. and then:

Modify classpath at runtime - controlling class loading order

此生再无相见时 提交于 2019-12-01 10:34:13
Is it possible to controll order of loaded classes at runtime? For example: I have class SomeClass which is in two jaras: SomeLibrary-1.0.jar and SomeLibrary-2.0.jar. The class have static method getVersion() which returns current version of SomeLibrary. I use solution found here to modify classpath at runtime. Now, when I run the code: public static void main(String[] args) { ClassPathHacker.addFile("SomeLibrary-1.0.jar"); ClassPathHacker.addFile("SomeLibrary-2.0.jar"); System.out.println(SomeClass.getVersion()); } I expect to see output 2.0 but there is 1.0 instead. This is because class

Setting CLASSPATH permanently

陌路散爱 提交于 2019-12-01 10:30:16
问题 In order to set my classpath environment variable, I'm running the following command: export CLASSPATH=/path/to/appropriate/dir In order to check that this was correctly set, I'll type echo $CLASSPATH and am returned /path/to/appropriate/dir. However, when I open up a new tab or window in the terminal echo $CLASSPATH returns nothing. What's going on here? 回答1: The variable you set in a terminal, is valid only for that terminal. What you should do is, export the variable in your ~/.bashrc file

GWT web-app vs system classpath for dynamic loaded classes

笑着哭i 提交于 2019-12-01 09:53:59
问题 In my GWT web app I am keeping all my jar files outside of my project and referencing them using classpath variables. This allows me to link to jars from other projects/teams without having to put a copy of the jar in my web app lib directory. Hosted mode kindly looks up the classes in this system classpath and then adds them to the web-app classpath warning me that it is doing so. When I deploy my build system pulls in only the jars I need to ship in my web app and is not a problem. The

Modify classpath at runtime - controlling class loading order

Deadly 提交于 2019-12-01 09:16:44
问题 Is it possible to controll order of loaded classes at runtime? For example: I have class SomeClass which is in two jaras: SomeLibrary-1.0.jar and SomeLibrary-2.0.jar. The class have static method getVersion() which returns current version of SomeLibrary. I use solution found here to modify classpath at runtime. Now, when I run the code: public static void main(String[] args) { ClassPathHacker.addFile("SomeLibrary-1.0.jar"); ClassPathHacker.addFile("SomeLibrary-2.0.jar"); System.out.println

Spring : PropertyPlaceholderConfigurer cannot find property file

╄→гoц情女王★ 提交于 2019-12-01 09:11:53
I have a strange problem with Spring using PropertyPlaceholderConfigurer . One of my beans is designed as follow : <bean name="propertyPlaceholder" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="locations"> <value>classpath:jdbc.properties</value> </property> </bean> The problem is that spring never find jdbc.properties ( FileNotFoundException ). The file is in a folder named "resources" that is in the bundle classpath (I am working in a OSGi project). I have tried almost every combination ("jdbc.properties", "/jdbc.properties", "classpath:jdbc

Adding to ColdFusion Classpath for Particular Instance in Multi-Server Adobe Coldfusion 9

不羁岁月 提交于 2019-12-01 08:33:10
Adobe ColdFusion 9 Multi-Server doesn't have the "JVM and Java Settings" page in the CF Admin, so to add something to the CF classpath, for a given instance, that instance must be started with an alternate jvm.config. I don't have a problem with starting with an alternate jvm.config. I do, however, have a problem knowing precisely how to edit that file in the proper way. My stock jvm.config looks like this (ignore line breaks--they are not in the actual file): java.args=-server -Xmx512m -Dcoldfusion.sessioncookie.httponly=true -Dsun.io.useCanonCaches=false -XX:MaxPermSize=192m -XX:

Spring ApplicationContext with multiple XML Files from Jar

亡梦爱人 提交于 2019-12-01 08:20:39
问题 I need to create a ApplicationContext with the "main" applicationContext-a.xml from the current Maven build. The other one wires classes from another maven build and is preset in the jar included by a Maven Dependency. Here the idea: ApplicationContext context = new ClassPathXmlApplicationContext( new String[] { "classpath*:applicationContext-*.xml"}); This should load applicationContext-a.xml from the Classpath because it's in the same Project. This works. Then applicationContext-b.xml

Loading two classes in different JARs

▼魔方 西西 提交于 2019-12-01 06:59:28
I got two classes with the same package in different JARs. Until the previous version, both classes were identical, so i had no issues in loading them. Now, one of them has a new method added and if I want to access it, not only should I import the class with that package, i also need to make sure the jar with the correct class comes first in the classpath. i.e. javac -classpath "%classpath%;a.jar;b.jar" MyClasses.. where a.jar has the class with my new method. Now, how do i ensure this when my app goes to production, where it's deployed as an EAR file, with all the libraries under WEB-INF/lib

Specifying classpath for a jar

↘锁芯ラ 提交于 2019-12-01 06:49:22
I am trying to configure the classpath of a JAR so that my ResourceBundle can pick up property files from it. If I run it from the .class files and specify the -cp flag it works fine, and System.err.println(System.getProperty("java.class.path")); will print the path specified in the -cp flag. If I try and create a jar file for it, System.err.println(System.getProperty("java.class.path")); always prints the path of the jar file, and the property files aren't picked up. It seems if you are running it as a jar file you can't specify the -cp flag (which was what I was hoping, as it's common to