classpath

How to get handle to a resource within a JSF class?

邮差的信 提交于 2019-11-28 05:21:46
问题 I've put a properties file within src/main/resources in my JSF project. How do I get a handle to it? I understand that EL doesn't work within a backing bean. Note: The file is in src/main/resources - NOT src/main/webapps/resources , so the following doesn't work: FacesContext context = FacesContext.getCurrentInstance(); File value = context.getApplication().evaluateExpressionGet(context, "#{resource['resources:email.properties']}", File.class); 回答1: It's thus in the classpath. You can just

Synchronizing Eclipse .classpath in code repository

落爺英雄遲暮 提交于 2019-11-28 05:13:43
问题 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

Android Eclipse Classpath - want to add classpath container path but eclipse won't let me

人盡茶涼 提交于 2019-11-28 04:59:44
I'm using Eclipse to learn to develop Android applications in Java. I haven't used Eclipse before. The project I'm trying to use (supplied by OReilly as part of 'Android Application Development') is MJAndroid. When attempting to run the project, the Run fails, and the Problems tab mentions com.java.Object can't be found, and Eclipse asks me to check the build path. Clicking Properties -> Java Build Path -> Libraries, the message 'Unable to get system library for the project' is displayed. On a working project, Properties -> Java Build Path -> Libraries has an entry for Android 1.1, which if I

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

别等时光非礼了梦想. 提交于 2019-11-28 04:58:31
问题 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 "/"

Load resource from class's own JAR file

只愿长相守 提交于 2019-11-28 04:48:56
问题 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? 回答1: Alternatively you could use the JarURLConnection if you know

File inside jar is not visible for spring

烂漫一生 提交于 2019-11-28 04:48:35
All I created a jar file with the following MANIFEST.MF inside: Manifest-Version: 1.0 Ant-Version: Apache Ant 1.8.3 Created-By: 1.6.0_25-b06 (Sun Microsystems Inc.) Main-Class: my.Main Class-Path: . lib/spring-core-3.2.0.M2.jar lib/spring-beans-3.2.0.M2.jar In its root there is a file called my.config which is referenced in my spring-context.xml like this: <bean id="..." class="..."> <property name="resource" value="classpath:my.config" /> </bean> If I run the jar, everything looks fine escept the loading of that specific file: Caused by: java.io.FileNotFoundException: class path resource [my

“Cannot find symbol” error - even on a ridiculously simple example

本小妞迷上赌 提交于 2019-11-28 04:47:35
问题 So I've been trying to solve this problem for a matter of hours now. I've scoured the internet, I've scoured StackOverflow, I've asked some co-workers (I'm an intern) and honestly no one can tell me what is going on! I put together a really really simple example to show you what I'm doing (and I get the error even with the simple example) I have two .java files. One is Test.java the other is testClass.java . //testClass.java package test; public class testClass { private int someMember=0;

IntelliJ gives Fatal Error: Unable to find package java.lang in classpath or bootclasspath

为君一笑 提交于 2019-11-28 04:36:13
When I try to make a simple module in IntelliJ it responds with: Fatal Error: Unable to find package java.lang in classpath or bootclasspath Somehow the JDK language jars were removed from the classpath. All I had to do was reapply the JSDK home path. Goto: File -> Project Structure -> Platform Settings -> SDKs Re-apply the JSDK home path. Doing this added about 15 jars to the classpath. Apparently these are important for compiling. File -> Project Structure -> Platform Settings -> SDKs, remove existing SDK and add it again. Works for me in IntelliJ 2017.3. This error happend to me after i've

Spring startup performance issues

大兔子大兔子 提交于 2019-11-28 03:40:46
I'm trying to integrate Spring in a pretty large application with thousands of classes, and i'm experiencing huge delays starting my container because of component-scanning. I have already narrowed the number of directories specified in the "base-package", to the minimum in order to reduce the time wasted in scanning irrelevant directories, but the class-path scanning part of initialization still takes about 1-2 mins. So, is there a way to optimize the scanning process ? I've thought of storing the candidate classes path in a file and make the container then get them from the file instead of

Why does ANT tell me that JAVA_HOME is wrong when it is not?

余生颓废 提交于 2019-11-28 03:38:55
I get the error: C:\dev\ws\springapp\build.xml:81: Unable to find a javac compiler; com.sun.tools.javac.Main is not on the classpath. Perhaps JAVA_HOME does not point to the JDK. It is currently set to "C:\Program Files\Java\jre6" But I have clearly set my JAVA_HOME to be C:\Program Files\Java\jdk1.6.0_14 Where is ANT getting this value? When you say you have "clearly set" JAVA_HOME to "C:\Program Files\Java\jdk1.6.0_14" - is that what you see when you run "set" from the command line? I believe Ant will guess at a value for JAVA_HOME if one isn't set at all... is it possible that you've set