classpath

Gradle: custom source set as dependency for the main and test ones

一笑奈何 提交于 2019-12-10 00:58:46
问题 I've created custom source set in Gradle project to keep all generated code: sourceSets { generated { java { srcDir 'src/generated/java' } resources { srcDir 'src/generated/resources' } } } I want to make the result of this source set's code compilation available at compile and run time for main and test source sets. What's the right semantic way to do it in Gradle? UPDATE: As suggested here: How do I add a new sourceset to Gradle? doesn't work for me, I still get java.lang

Using JavaCompiler in an OSGi Bundle

懵懂的女人 提交于 2019-12-09 17:41:00
问题 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>() {...};

Java Classpath and relative paths

倖福魔咒の 提交于 2019-12-09 16:43:30
问题 If you have a relative path in the java class path, does this just search the current working directory. Does the same hold for class paths declared in a manifest file. In a manifest file is it relative to the dir the jar is in? Ex. Cmdline java -cp somejar.jar Or Manifest Class-Path: somejar.jar 回答1: If you say -cp somejar.jar you are adding somejar.jar to the classpath. It will only try to find the somejar.jar from the directory you are currently in when you typed the command. If you say in

How to include all the jars present at a particular directory in the CLASSPATH in one go? [duplicate]

隐身守侯 提交于 2019-12-09 07:41:31
问题 This question already has answers here : Including all the jars in a directory within the Java classpath (25 answers) Closed 2 years ago . I have around hundreds of jars at a particular directory which my application uses. So I thought its hard to add each jars one by one to the classpath. So is there any command or any way so that i can add all the jars at one go. some *.jar should add all the jars. 回答1: Yes, you can use a wildcard, as of Java6. See the section on "Understanding class path

how to set classpath for a Java program on hadoop file system

只愿长相守 提交于 2019-12-09 06:25:43
问题 I am trying to figure out how to set class path that reference to HDFS? I cannot find any reference. java -cp "how to reference to HDFS?" com.MyProgram If i cannot reference to hadoop file system, then i have to copy all the referenced third party libs/jars somewhere under $HADOOP_HOME on each hadoop machine...but i wanna avoid this by putting files to hadoop file system. Is this possible? Example hadoop command line for the program to run (my expectation is like this, maybe i am wrong):

How to programmatically call a Maven-task

六眼飞鱼酱① 提交于 2019-12-09 04:38:54
问题 I'm using Maven in the context of another build-tool (leiningen for Clojure, but this should not matter), and I would like to know how I would call a plugin like dependency:build-classpath programmatically (i.e. via the Maven-API, not via the mvn -command). 回答1: See how org.apache.maven.plugin.testing.AbstractMojoTestCase from maven-plugin-testing-harness is implemented. Here's a code snippet from some of my tests which may be helpful. public abstract class JAXBGenerateTest extends

Add properties file to build path of runnable jar

≡放荡痞女 提交于 2019-12-09 01:38:08
问题 is it possible to add to the classpath of a runnable jar file some properties file? I tryed these solutions solutions: running the executable file using the following command: java -cp ../prop_dir/prop1.properties;../prop_dir/prop2.properties -jar MyRunnableJar.jar adding to the MANIFEST FILE (in the Class-Path section) ../prop_dir/prop1.properties ../prop_dir/prop1.properties but none of them works. The architecture of the running dir is the following + + MyRunnableJar.jar + prop_dir/ +

Why can I use a Java lib from the Scala REPL but not from a script?

不羁岁月 提交于 2019-12-08 21:23:49
问题 I’m working on a Scala script which uses Joda Time. Up until today, this was working fine. Somehow, something’s changed and it’s no longer working. This works: $ scala -cp "lib/*" Welcome to Scala version 2.9.1.final (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_29). Type in expressions to have them evaluated. Type :help for more information. scala> import org.joda.time._ import org.joda.time._ scala> Period.minutes(5) res0: org.joda.time.Period = PT5M but this doesn’t: $ scala -cp "lib/*"

Eclipse - Setting .classpath file for existing project

风格不统一 提交于 2019-12-08 19:55:36
问题 I have a java project. The working folder from someone else's Eclipse project (It was a Repast Simphony project I think). In my eclipse I created a new Java project and told it to use the existing code. So it seems to have brought in all the code. However after loading the project I get this error: Project 'My Project' is missing required Java project: 'Weka 3-7' It has a .classpath file with these contents: <?xml version="1.0" encoding="UTF-8"?> <classpath> <classpathentry kind="src" path=

Ant JUnit ClassNotFoundException

こ雲淡風輕ζ 提交于 2019-12-08 18:49:23
问题 I realize there are a lot of similar questions as this one, however after reading over most of them I seem to be having the same problem, but for different reasons. I'm running a <junit> task inside my Ant build and am getting a ClassNotFoundException . In most of the similarly-related questions (such as the one above), this turned out to be various degrees of the author simply not configuring the JUnit classpath correctly. Although it may very well be the same for me, none of the suggestions