classpath

Can I force the order of dependencies in my classpath with Gradle?

微笑、不失礼 提交于 2019-11-28 14:14:50
I know I'm going very much against the grain hear but here me out... I have a project that runs on Google App Engine. The project has dependency that uses a class that can't be invoked on App Engine due to security constraints (it's not on the whitelist ). My (very hacky) solution was to just copy a modified version of that class into my project (matching the original Class's name and package) that doesn't need the restricted class. This works on both dev and live, I assume because my source appears in the classpath before my external dependencies. To make it a bit cleaner, I decided to put my

Getting a java.lang.ClassNotFoundException even though i've specified the correct jar with -cp

社会主义新天地 提交于 2019-11-28 13:43:05
java.lang.ClassNotFoundException: com.hazelcast.core.Hazelcast This bit is strange though, because i've added hazelcast-1.8.5.jar to the classpath when i'm running java: java -cp hazelcast-1.8.5.jar -jar myapp.jar So i cannot understand why i'm getting the ClassNotFoundException, when the hazelcast jar is well and truly present, and specified in the command line. Any ideas please? By the way, hazelcast is pretty fricking sweet! From the -jar option docs : When you use this option, the JAR file is the source of all user classes, and other user class path settings are ignored. You need to set

Setting up java classpath and java_home correctly in Ubuntu

限于喜欢 提交于 2019-11-28 12:09:57
I am getting the error Exception in thread "main" java.lang.NoClassDefFoundError: When I try and run a compiled class on Ubuntu. I am using a very simple Helloworld example, and the millions of responses which already exist on the internet suggest that my CLASSPATH and JAVA_HOME variables have been incorrectly set. However, I have edited the etc/environment to the correct folders as well as the current folder: PATH=".:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games" JAVA_HOME="/usr/lib/jvm/java-1.5.0-sun/" CLASSPATH=".:/usr/lib/jvm/java-1.5.0-sun/lib" and they appear

How do I add jar files to the Classpath? [closed]

混江龙づ霸主 提交于 2019-11-28 12:09:37
I'm on Windows and I've tried the -classpath under javac to no avail. Also tried moving the jar to the src directory, but java file still won't compile. Trying to do a simple import of httpclient in the script. import org.apache.http.client.*; Install your JDK and leave it alone . Do not copy .jar files into your JDK folders! I'd recommend getting an IDE like Eclipse or Netbeans, if you don't already have one. I would set up a new project, create or import your source, and set a class path for the project. If that doesn't work, please tell us: a) your OS and version b) your JDK and version c)

Finding the path to a jar from a Class inside it?

≡放荡痞女 提交于 2019-11-28 11:49:21
Plugin x.y.z is supposed to run on top of a Java project and generate some Java-Code. This code will need classes available in the Plugin's jar at build and run time. Hence, the Plugin's jar (or installation directory) should appear in the build classpath. How can a plugin find out the exact path of it's own jar/installation directory, or, for that matter, the path to the jar of some associated plugin in a portable way? Background is I want to make a wizard that the user can run to enable x.y.z. nature on a project. The user should be provided with a meaningful default for where to find the

does JWS support to launch One-Jar

血红的双手。 提交于 2019-11-28 11:38:03
问题 Can I supposed to launch One-Jar using JWS? One-JAR provides custom classloader that knows how to load classes and resources from a jars inside an archive whereas in JWS we need to specify each JAR that is being used in resources. What I supposed to specify in JNLP if I am trying to launch One-Jar - <?xml version="1.0" encoding="UTF-8"?> <jnlp spec="1.0+" codebase="" href=""> <information> <title>Application</title> <vendor>ABC</vendor> </information> <resources> <!-- Application Resources --

groovy script classpath

为君一笑 提交于 2019-11-28 11:27:01
I'm writing a script in Groovy and I would like someone to be able to execute it simply by running ./myscript.groovy . However, this script requires a 3rd party library (MySQL JDBC), and I don't know of any way to provide this to the script other than via a -classpath or -cp argument, e.g. `./monitor-vouchers.groovy -cp /path/to/mysql-lib.jar` For reasons I won't go into here, it's not actually possible to provide the JAR location to the script using the -classpath/-cp argument. Is there some way that I can load the JAR from within the script itself? I tried using @Grab import groovy.sql.Sql

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

戏子无情 提交于 2019-11-28 11:26:48
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 image = ImageIO.read(is); System.out.println(image); } } See the attachment for 2 test cases. First,

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

耗尽温柔 提交于 2019-11-28 11:21:12
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? 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] Might not be the easiest method, but you could look at what files the process has open and determine it from that. If you're on windows you could use Process Explorer to see what files the process has

What exactly is a class path in java?

断了今生、忘了曾经 提交于 2019-11-28 11:02:32
I wrote a program that works on my laptop perfectly, but I really want it to work on a server that I have. Using NetBeans , I've clean and built the project. I copied the contents of the folder dist on my server but I cannot seem to get to work by using command java -jar nameOfFile.jar I get the error java.lang.NoClassDefFoundError: org/.... I have been doing some reading and from what I gather is that I need to pretty much specify where the libraries that I've used are located. Well they are located in a subfolder called lib. Question: So what would I need to do in order to be able to run my