classpath

How do I place jars in jetty/lib on the jetty classpath?

↘锁芯ラ 提交于 2019-12-01 15:59:28
问题 I have Jetty jetty-9.2.3.v20140905 My understanding was that jars in lib/jar or lib/ext were automatically on the classpath, but this may have been old behavior from jetty 8. I'm trying to deploy a webapp with websockets. With my deployed WAR file in the webapps directory, jetty keeps complaining that it cannot find jars sitting right there in the jetty/lib directory (jetty-http, jetty-io, jetty-security, jetty-server, jetty-servlet, jetty-util are the ones my webapp needs that it cannot find

How can I discover resources in a Java jar with a wildcard name?

人走茶凉 提交于 2019-12-01 15:56:07
问题 I want to discover all xml files that my ClassLoader is aware of using a wildcard pattern. Is there any way to do this? 回答1: It requires a little trickery, but here's an relevant blog entry. You first figure out the URLs of the jars, then open the jar and scan its contents. I think you would discover the URLs of all jars by looking for `/META-INF/MANIFEST.MF'. Directories would be another matter. 回答2: A Spring ApplicationContext can do this trivially: ApplicationContext context = new

Maven Archiver putting in weird line breaks in classpath for manifest

混江龙づ霸主 提交于 2019-12-01 15:51:45
Per the java spec the classpath line in the manifest.mf for a jar can only be a certain number of bytes. After that a line break is inserted and the new line begins with an empty space. Using Maven 3, and maven-jar-plugin version 2.3.2 my manifest ends up with some interesting line breaks in the classpath and I think that may be breaking my EAR when deployed into WAS 7. Just want to make sure the manifest is OK to look like that (may not match byte length but so you get the picture): Class-Path: log4j-1.2.16.jar projectthatislong-0.0.1-SNAPSHOT.jar projectt hatislong-0.0.1-SNAPSHOT.jar Notice

Combining Jar file with -classpath JAVA

情到浓时终转凉″ 提交于 2019-12-01 13:50:21
I have a question regarding compiling a class which has some dependent classes in a Jar file ( MyJar.jar ). By putting a directory tree in a -classpath option (ex: javac -cp MyJar MyClass.java ), will all the subdirectories be checked for classes or only the top level classes in the directory tree? Thanks in advance. will the directories specified with -cp be recursivly searched: No when the classloader enters a directory specified in the classpath it starts using the package where the class is located as subdirectory. if no package is specified then the classloader will expect it under the

How to set the classpath in Java?

纵饮孤独 提交于 2019-12-01 13:45:20
I've many jar files to add to my classpath, so everytime I compile my java file I end up with a command like this: javac -cp commons-digester-2.1/commons-digester-2.1.jar:lucene-core-3.0.3.jar:commons-logging-1.1.1/commons-logging-1.1.1.jar:commons-beanutils-core-1.7.0.jar:. CollectionIndexer.java I've tried to use: set CLASSPATH=commons-digester-2.1/commons-digester-2.1.jar:lucene-core-3.0.3.jar:commons-logging-1.1.1/commons-logging-1.1.1.jar:commons-beanutils-core-1.7.0.jar:. and then: javac CollectionIndexer.java but the jar are not added at all: I get error due to the missing jars...

Setting CLASSPATH permanently

寵の児 提交于 2019-12-01 13:16:47
In order to set my classpath environment variable, I'm running the following command: export CLASSPATH=/path/to/appropriate/dir In order to check that this was correctly set, I'll type echo $CLASSPATH and am returned /path/to/appropriate/dir. However, when I open up a new tab or window in the terminal echo $CLASSPATH returns nothing. What's going on here? The variable you set in a terminal, is valid only for that terminal. What you should do is, export the variable in your ~/.bashrc file, which is loaded for each terminal. So, add that statement in the .bashrc file, and you'll be fine. You can

Ant + Class-path Issue

回眸只為那壹抹淺笑 提交于 2019-12-01 12:54:24
问题 I have written an ANT script and finally am building the jar here is the building of jar section <jar jarfile="${destination}/@{name}.jar"> <fileset dir="${output}"> <include name="abc/xyz/@{name}/**"/> </fileset> <zipfileset dir="lib" prefix="lib/"/> <manifest> <attribute name="Main-Class" value="com.abc.xyz.HelloWorld"/> <attribute name="Class-Path" value=".:lib/activation.jar:lib/antlr-2.7.6.jar:lib/asm-attrs.jar:lib/asm.jar:lib/cglib-2.1.3.jar:lib/commons-collections-2.1.1.jar:lib/commons

Java Connecting to remote MySQL database

三世轮回 提交于 2019-12-01 12:15:22
Hey guys im trying to connect to my remote mysql database and my code gives me this error: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver at java.net.URLClassLoader$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Unknown Source) at Login.login(Login.java:116) at Login

Listing items on the Java classpath from the current project only

别来无恙 提交于 2019-12-01 11:56:44
问题 I have a Java project with a large classpath - many of the items are imported from different .jar files that have been added as dependencies (via Maven). I'm looking for a programmatic way to list all the items on the classpath that come from the current project, i.e. excluding all the imported classpath items from other libraries and the Java runtime environment itself. I need to do this at runtime, i.e. it should work off the actual current classpath. Is there a good way to do this, and if

Spring ApplicationContext with multiple XML Files from Jar

馋奶兔 提交于 2019-12-01 11:14:04
I need to create a ApplicationContext with the "main" applicationContext-a.xml from the current Maven build. The other one wires classes from another maven build and is preset in the jar included by a Maven Dependency. Here the idea: ApplicationContext context = new ClassPathXmlApplicationContext( new String[] { "classpath*:applicationContext-*.xml"}); This should load applicationContext-a.xml from the Classpath because it's in the same Project. This works. Then applicationContext-b.xml should be loaded from the dependency-jar. This doesn't work. Note that "classpath*:applicationContext-*.xml"