classpath

Synchronizing Eclipse .classpath in code repository

孤街浪徒 提交于 2019-11-29 11:29:34
My team handles several Java projects using Eclipse, and shares the code using a code repository. When a developer adds, removes or updates a jar file, the build is broken for everybody else, until they update their build path in Eclipse. This process involves cumbersome email synchronization. For several reasons, we have decided not to commit the .classpath file to the repo. Instead, we came up with the following idea: Each project will have a committed file, say jars.list , which contains a list of jar files (and patterns). A script will convert this file into a local .classpath for eclipse.

Load resource from class's own JAR file

我只是一个虾纸丫 提交于 2019-11-29 11:06:46
When using Class.getResource() and supplying a rather common resource name, like "license.html" , Java may load a "license.html" resource from another JAR file which is listed earlier in the CLASSPATH, but may be completely unrelated to my application. Is there a way to force the ClassLoader to first try to load the resource from the same JAR file which my class is in and only if not found, look in other JARs on the CLASSPATH? Alternatively you could use the JarURLConnection if you know the exact jar in which your file resides: jar:<url>!/{entry} ..common resource name, like "license.html"' A

getClass().getResource(“/”) returns null in command line

ⅰ亾dé卋堺 提交于 2019-11-29 11:06:22
I'm trying to read a file in my maven project at /src/main/resources/file.txt. I'm using URL url=this.getClass().getResource("/"); String filePath=url.getPath()+"file.txt"; url object gets the correct value when this is run thru eclipse. But, when I package the jar and run it in command line: jar -cp myjar.jar SampleTest It returns null for 'url' object and throws a NullPointerException in the next line. I have openend my Jar file using file browser and checked. It has the 'file.txt' in "/" location inside the Jar. Where am I going wrong ? There are (often) no directories inside jar files.

Could not locate clojure/core/async__init.class or clojure/core/async.clj on classpath

微笑、不失礼 提交于 2019-11-29 10:02:37
Does anyone know why I'm getting the below error? I read through answers of similar questions, which recommended using Leiningen, which I've done below and still get the error. MacBook-Pro:~ xxx$ lein new app test Generating a project called test based on the 'app' template. MacBook-Pro:~ xxx$ cd test MacBook-Pro:test xxx$ lein repl nREPL server started on port 59623 on host 127.0.0.1 REPL-y 0.2.1 Clojure 1.5.1 Docs: (doc function-name-here) (find-doc "part-of-name-here") Source: (source function-name-here) Javadoc: (javadoc java-object-or-class-here) Exit: Control+D or (exit) or (quit)

Using JPA 2.1 in EAP 6.4.0

。_饼干妹妹 提交于 2019-11-29 10:01:23
问题 I searched for a solution for this problem without having success so far. We're migrating our aplications over to EAP 6.4.0, and our applications relies on JPA 2.1. However, JBoss is a Java EE 6 server, and therefore includes JPA 2.0 in the form of a module. I tried including the JPA API jar directly in my WEB-INF/lib directory, thinking the classloader would prefer this one over the one from the system. I have tried to include a jboss-deployment-structure.xml file in my ear. I tried it under

working directory in sbt

青春壹個敷衍的年華 提交于 2019-11-29 09:47:13
I would like to be able to run the java program in a specific directory. I think, that it is quite convenient to parametrize working directory, because it allows to easily manage configurations. For example in one folder you could have configuration for test, in other you could have resources needed for production. You probably think, that there is option to manipulate classpath for including/exluding resources but such solution works only if you are interested in resources stored in classpath and referencing them using Classloader.getResource(r) . But what if you have some external

How to set classpath for mvn exec:exec?

巧了我就是萌 提交于 2019-11-29 09:42:51
问题 I'm trying to have mvn exec:exec (or mvn exec:java ) run my program with a local jar in the classpath. However the jar fails to load: Exception in thread "main" java.lang.Error: Unable to load voice directory. java.lang.ClassNotFoundException: com.sun.speech.freetts.en.us.cmu_us_slt_arctic.ArcticVoiceDirectory at com.sun.speech.freetts.VoiceManager.getVoiceDirectories(VoiceManager.java:211) at com.sun.speech.freetts.VoiceManager.getVoices(VoiceManager.java:111) at com.sun.speech.freetts

getClass().getClassLoader().getResourceAsStream() is caching the resource

末鹿安然 提交于 2019-11-29 09:25:35
I have a resource (velocity template) which I'd like to be able to swap during development. However, getClass().getClassLoader().getResourceAsStream() seems to cache the template. Is there a way to disable this besides using a file loader instead of the class loader? To avoid caching you can use: getClass().getClassLoader().getResource().openStream() It would be equal to using URLResourceLoader for Velocity instead of ClasspathResourceLoader I suppose. I would just go with a file loader. See if something like this helps (exception handling omitted): URL res = getClass().getClassLoader()

HttpClient NoClassDefFoundError

ぐ巨炮叔叔 提交于 2019-11-29 09:23:22
I am trying to run a sample application from HttpClient 4.0.1. It is the file ClientMultiThreadedExecution.java from the examples section. I put in these files in the classpath: apache-mime4j-0.6.jar ; commons-codec-1.3.jar ; commons-logging-1.1.1.jar ; httpclient-4.0.1.jar ; httpcore-4.0.1.jar ; httpmime-4.0.1.jar and the file compiles correctly. At runtime I get the following error: Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/http/client/methods/HttpUriRequest Caused by: java.lang.ClassNotFoundException: org.apache.http.client.methods.HttpUriRequest at java.net

Can I use the classpath to override a file in a jar that is being run?

痴心易碎 提交于 2019-11-29 09:16:38
I have a JAR file that contains an application as well as configuration files for that application. The application loads configuration files from the classpath (using ClassLoader.getResource() ), and has its dependencies completely satisfied using the configuration files baked into the JAR file. On occasion I want the application to be run with a slightly different configuration (specifically I want to override the JDBC URL to point to a different database) so I create a new configuration file, store it in the correct directory structure (which means in a directory /config of a classpath