classpath

How to pass local filename to ClassPathXmlApplicationContext?

耗尽温柔 提交于 2019-12-04 09:52:04
By "local filename" I mean that resource file is located in the same directory as class file. In the case below this is JUnitRunner.class file. Java's getResource() file can handle this if path does not start with / ' I can't figure out, how to do the same ClassPathXmlApplicationContext constructor? package springtests; import java.io.File; import java.net.URISyntaxException; import java.net.URL; import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.context.support.ClassPathXmlApplicationContext; public class JUnitRunner { private final

Setting Java Classpath to Load a Class File

风流意气都作罢 提交于 2019-12-04 09:33:54
问题 I'm new to Java, and I'm unsure how to access a class file located in a specific directory from a separate program jar. For example, I have an third party jar file located in /, which is supposed to load MyClass located in /mylib/MyClass.class, so I tried running: java -jar mainprog.jar -classpath "/mylib" MyClass but I'm getting the error: Exception in thread "main" java.lang.NoClassDefFoundError: MyClass Caused by: java.lang.ClassNotFoundException: MyClass at java.net.URLClassLoader$1.run

how to load the dependencies from the pom into classpath of eclipse project?

匆匆过客 提交于 2019-12-04 09:00:19
Am using eclipse helios with m2eclipse plugin. For a maven project checked out from CVS, how do i tell eclipse to automatically fetch all the jars needed for that project from the dependencies mentioned in the pom. Thanks for your time m2eclipse should do this for you (dependencies will be copied to your local repository) and build a valid classpath. I you have any doubts that the resolved dependencies are outdated try <select project> -> Context Menu -> Maven -> Update Dependencies If you want to guarantee that all dependencies (and plugins) are in your local repository you can run the go

getting JRE system library unbound error in build path

纵饮孤独 提交于 2019-12-04 08:52:00
问题 getting a JRE system library unbound error in build path, tried all suggestions from the below links, however did not work. I have jdk 1.6.0_29, I have also tried to install other versions but no help. JRE System Library [WebSphere v6.1 JRE] (unbound) Eclipse error: Unbound classpath container Java - Unbounded classpath container Websphere V6 JRE Struggling to update JRE dependencies within Maven and Eclipse Unbound classpath container in Eclipse unbound class path container error in eclipse?

Easiest way to manage my CLASSPATH?

泪湿孤枕 提交于 2019-12-04 08:28:34
I'm beginning to play with Clojure a bit and my Java experience is pretty limited. I'm coming from the dynamic world of Ruby and OO, so the functional side of things is very interesting! Anyway, as I discover libraries and various tools for use (and the tutorial files for the Pragmatic Clojure Book), everything typically calls for placing files in the CLASSPATH in order for Clojure to see the library for use. Is there such thing as good CLASSPATH practice? Would I ever want to only have a CLASSPATH with just the external libraries of files I need or can I go ahead toss any library or file I

Adding referenced jars to android build.xml

风格不统一 提交于 2019-12-04 06:17:32
I have an android eclipse project and have generated the corresponding build.xml ant file by doing: android update test-project -p . -m ..\main_project This compiles fine. However, in eclipse I have then added three referenced external jars (easymock, objenesis and cglib). In eclipse everything builds fine but then when I run the above command again it doesn't add these jars to the classpath. So my question is how to tell the build.xml to include these jars? I have done some research first and some people suggested changing the rules files in the sdk itself but this is something I want to

Cannot find main class on Linux - Classpath issue

一曲冷凌霜 提交于 2019-12-04 06:12:56
问题 I am having some trouble running a few jar's on a linux box. Basically, I am getting an error saying it cannot find the main class of my main jar. The class is defenetly present so it must be a classpath issue. I am not great with linux, so I am looking for some advice as to where I might be missing something. First off, I am setting the classpath in the users bash_profile; adding all the jar's required, seperated by a : delimeter. I then export the classpath. Then, in the shell (ksh) script

Using JavaCompiler in an OSGi Bundle

Deadly 提交于 2019-12-04 05:51:47
I'm in the process of refactoring a Java application to use OSGi. One feature of the application is on-the-fly Java compilation using javax.tools.JavaCompiler . In the original application this process worked by feeding the compiler the existing classpath, like so. JavaCompiler compiler = ToolProvider.getSystemJavaCompiler(); String[] options = {"-classpath", System.getProperty("java.class.path")}; DiagnosticListener<JavaFileObject> listener = new DiagnosticListener<JavaFileObject>() {...}; StandardJavaFileManager fileManager = compiler.getStandardFileManager(listener, null, null); Iterable<?

IntelliJ: How to add all jar files in a folder to classpath

喜欢而已 提交于 2019-12-04 05:29:12
问题 I recently opened a Maven project with the pom.xml file: <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.example</groupId> <artifactId>demo</artifactId> <version>0.0.1-SNAPSHOT</version> <packaging>jar</packaging> <name>demo</name> <description>Demo

Printing OSGI bundle classpath?

不羁岁月 提交于 2019-12-04 05:21:38
In a normal java application its possible to print the content of the classpath with: String ss = System.getProperty("java.class.path"); System.out.println(ss); But how do I print the classpath of an OSGI bundle created using the eclipse PDE wizard? In the activator its possible to get the current bundle like: public void start(BundleContext context) throws Exception { super.start(context); plugin = this; Bundle b = context.getBundle(); // java doc: This bundle's class loader is not used to search for entries. b.findEntries(path, filePattern, recurse) But the javadoc says that the findEntries