classpath

How to analyse which jar file is used in a Java program?

一个人想着一个人 提交于 2019-11-27 06:14:57
问题 Suppose there is a jar file named callme.jar and it's located in several directories, how to analyse which one of them is used at run-time? 回答1: Invoke the java executable with the -verbose:class argument. This will produce output like: [Loaded org.apache.log4j.helpers.ThreadLocalMap from file:/C:/.../1.2.14/log4j-1.2.14.jar] [Loaded org.apache.commons.cli.Option from file:/C:/.../commons-cli-1.2.jar] 回答2: Might not be the easiest method, but you could look at what files the process has open

Unable to open resources in directories which end with an exclamation mark (!)

落花浮王杯 提交于 2019-11-27 06:12:56
问题 The getResourceAsStream-method returns null whenever running the executable jar in a directory which ends with a exclamation mark. For the following example, I have a Eclipse project the following directory structure: src\ (Source Folder) main\ (Package) Main.java res\ (Source Folder) images\ Logo.png I'm reading the Logo.png as follows: public static void main(String[] args) throws IOException { try (InputStream is = Main.class.getClassLoader().getResourceAsStream("images/Logo.png")) { Image

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

坚强是说给别人听的谎言 提交于 2019-11-27 05:32:03
问题 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

IntelliJ can't find classpath test resource

∥☆過路亽.° 提交于 2019-11-27 05:21:10
问题 I'm having a problem where IntelliJ 13.1.4, when running a unit test, can't find a ServiceLoader file in the src/test/resources directory of my module. Please note before answering that I've done all of the following: The module is a Gradle project, and if I run gradle test the unit test runs fine. I've run this unit test successfully in IntelliJ in the past, and it found the module. (Maybe an earlier version of IntelliJ?) I've double checked the IntelliJ module settings and the src/test

read file in classpath

孤街醉人 提交于 2019-11-27 05:13:15
问题 Here is what I want to do and I am wondering if there is any Spring classes that will help with implementing. I don't have to use spring for this particular problem, I'm just implementing it with everything else. In my DAO layer I want to externalize my sql files aka 1 sql per file. I want to read and cache the sql statement even maybe as a spring bean singleton. But in my initial struggles, I am having a problem just loading a sql file in the classpath... Is there anything in spring to help

Spring startup performance issues

时光总嘲笑我的痴心妄想 提交于 2019-11-27 05:11:40
问题 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

Add jar to classpath at runtime under java 9

China☆狼群 提交于 2019-11-27 05:05:51
Until java9 for adding external jar to classpath in runtime by programmatically everybody used: URLClassLoader sysloader = (URLClassLoader) ClassLoader.getSystemClassLoader(); Method method = URLClassLoader.class.getDeclaredMethod("addURL", new Class[]{URL.class}); method.invoke(sysloader, new Object[]{file.toURI().toURL()}); Now with java9 we have problem: Exception in thread "main" java.lang.ClassCastException: java.base/jdk.internal.loader.ClassLoaders$AppClassLoader cannot be cast to java.base/java.net.URLClassLoader URLClassLoader doesn't work anymore in Java 9. What to do now under jdk9

Android - Command not found

*爱你&永不变心* 提交于 2019-11-27 05:04:12
问题 I am trying to run the command in ubuntu android update project --path . However I am getting a android:command not found error. I assume this is something to do with the path which I learnt on here the other day? I was just wondering, what do variable do I need to add (Android I assume) and what do I need to point it too. 回答1: On MacOS/Linux, define the path to wherever you installed your SDK as ANDROID_HOME : MacOS $ export ANDROID_HOME=/Applications/android-sdk-macosx If you installed

How to run a java class with a jar in the classpath?

[亡魂溺海] 提交于 2019-11-27 04:47:26
So, I can do this very well: java mypackage.MyClass if ./mypackage/MyClass.class exists. I can also happily do this: java -cp myjar.jar mypackage.MyClass if the class file exists in the appropriate part of the jar. Easy stuff. But I can't for the life of me manage to do something like this: java -cp utilities.jar mypackage.MyClass where ./mypackage/MyClass.class exists, and where ./utilities.jar exists (not containing MyClass, of course). Am I about to feel stupid? Possibly :) # On Unix java -cp utilities.jar:. mypackage.MyClass # On Windows java -cp utilities.jar;. mypackage.MyClass Basically

Getting Ant <javac> to recognise a classpath

有些话、适合烂在心里 提交于 2019-11-27 04:10:47
I have an Apache Ant build file with a <javac> command that requires four specific JARs to be on the build classpath . I've tried to do this: <project basedir=".." default="build_to_jar" name="Transnet Spectrum Analyzer"> <property environment="env"/> <property name="src" value="src"/> <property name="libsrc" value="library_sources" /> <property name="build" value="build"/> <property name="dist" value="dist"/> <property name="target" value="1.5"/> <property name="libraries" value="./libraries"/> <fileset dir="." id="TSA.classpath"> <include name="${libraries}/rxtx/RXTXcomm.jar" /> <include