classpath

How to pass local filename to ClassPathXmlApplicationContext?

限于喜欢 提交于 2019-12-06 05:36:57
问题 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

classpath - running a java program from the command line

为君一笑 提交于 2019-12-06 05:20:58
问题 My code compiled fine with the following command: javac -cp "../lib/*" AvroReader.java (lib is where i put my jar files) At run time I get a ClassNotFoundException on the following line: DatumReader<?> dtmrdr = new GenericDatumReader(); It says it can't find org.apache.avro.generic.GenericDatumReader even though I've imported it. Why this is happening? Thanks! 回答1: Importing has nothing to do with loading classes or setting CLASSPATH. Try this: java -cp .;../lib/* Generator Using the dot '.'

Using maven 3, how to use project classpath in a plugin?

佐手、 提交于 2019-12-06 05:17:35
问题 I'm writing a maven 3 plugin, for which I would like to use project classpath. I've tried using the approach mentionned in Add maven-build-classpath to plugin execution classpath, but it seems the written component is not found by maven. (I have a ComponentNotFoundException at plugin execution start). So, what is the "reference" way to use project classpath in a maven 3 plugin ? Or if the component way is the right one, is there any configuration step beside adding the component as

Custom Java PMD rule: Can't find the class CustomRule

走远了吗. 提交于 2019-12-06 05:10:56
I'm trying to write custom PMD rules in Java. I have created a custom ruleset that looks like this: <?xml version="1.0"?> <ruleset name="Custom Ruleset" xmlns="http://pmd.sourceforge.net/ruleset/2.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 http://pmd.sourceforge.net/ruleset_2_0_0.xsd"> <description> My custom rules </description> <rule name="CustomRule" message="Custom message" class="mwe.CustomRule"> <description> Custom description </description> <priority>3</priority> </rule> </ruleset> I call pmd.bat using this

Bundling JAR dependencies with executable JAR (Über JAR) from command line

戏子无情 提交于 2019-12-06 03:52:35
问题 I'm trying to create an executable jar from the command line. The main class in the JAR has dependencies that i have packaged into another plain JAR file. I want to package the dependency JAR together with the executable JAR in order to have a single JAR file to ship. What i have tried so far is the following: The dependency Hello.class file has the mock code: public class Hello { public String getHello() { return "Well hello there!!"; } } I have packaged class file into hello.jar using: jar

Running Mahout from the command line (CLASSPATH)

假装没事ソ 提交于 2019-12-06 03:40:45
Complied Mahout successfully under Windows using Maven. I'm trying to run one of the examples from the command line and I don't get what I am doing wrong. Seems like a CLASSPATH problem. Let's say I want to run the GroupLensRecommenderEvaluatorRunner example. I go to the folder with the GroupLensRecommenderEvaluatorRunner.class file in it and execute: java -cp C:/mahout/core/target/classes;. org.apache.mahout.cf.taste.example.grouplens.GroupLensRecommenderEvaluatorRunner It gives me the NoClassDefFoundError exception for the GroupLensRecommenderEvaluatorRunner class. Is the path for -cp wrong?

Is it possible load all properties files contained in a package dynamically? i.e. MyClass.class.getResource('*.properties');

橙三吉。 提交于 2019-12-06 03:08:41
问题 I am familiar with obtaining the contents of a properties file given the name of the file, and obviously MyClass.class.getResource('*.properties') will not work, but how can I obtain a list of ALL the properties files located in the same package as my class? 回答1: You can do these sort of things with Spring . See 4. Resources, particurlarely (or notabily ? ) (or principalementely ? ) (or mainly ? ) at 4.7.2 Wildcards in application context constructor resource paths. 回答2: Assuming that it's

Classpath issues running Tika on Spark

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-06 02:50:00
I try to process a bunch of files in Tika. The number of files is in the thousands so I decided to build an RDD of files and let Spark distribute the workload. Unfortunatly I get multiple NoClassDefFound Exceptions. This is my sbt file: name := "TikaFileParser" version := "0.1" scalaVersion := "2.11.7" libraryDependencies += "org.apache.spark" %% "spark-core" % "1.5.1" % "provided" libraryDependencies += "org.apache.tika" % "tika-core" % "1.11" libraryDependencies += "org.apache.tika" % "tika-parsers" % "1.11" libraryDependencies += "org.apache.hadoop" % "hadoop-client" % "2.7.1" % "provided"

Printing OSGI bundle classpath?

拈花ヽ惹草 提交于 2019-12-06 01:57:13
问题 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

Get file in the resources folder in Java

做~自己de王妃 提交于 2019-12-05 23:35:50
问题 I want to read the file in my resource folder in my Java project. I used the following code for that MyClass.class.getResource("/myFile.xsd").getPath(); And I wanted to check the path of the file. But it gives the following path file:/home/malintha/.m2/repository/org/wso2/carbon/automation/org.wso2.carbon.automation.engine/4.2.0-SNAPSHOT/org.wso2.carbon.automation.engine-4.2.0-SNAPSHOT.jar!/myFile.xsd I get the file path in the maven repository dependency and it is not getting the file. How