classpath

In java EE, which jars should I put in the library dir?

会有一股神秘感。 提交于 2019-12-30 08:13:15
问题 I have a Java EE project. The project is built using maven into an .ear archive. There is a library jar containing a JPA 2 persistence unit, which is located in the library directory of the ear (so multiple other modules can use it). While adding an implementation of Shiro's Permission interface as an entity in this persistence unit, I had trouble getting the ear to deploy correctly, because the shiro classes where unavailable in the persistence unit. I eventually figured out that I needed to

Java : programmatically determine all of the package names loaded on the classpath

廉价感情. 提交于 2019-12-30 08:13:10
问题 Any suggestions as to how to approach how I would find out a list of package names that exist on the current classpath ? This needs to be done programmatically at run time by one of the classes loaded (and executing) on the classpath (i.e. inside out , not outside in). More details: One approach I considered was to use reflection on each of the classes loaded thus far by the class loader, and extract the package names from them. However, my application already runs into thousands of classes,

How to include the lib folder in the manifest classpath in Netbeans

放肆的年华 提交于 2019-12-30 07:29:07
问题 A library that my java application uses needs looks for a file (log4j.xml) in the class path. I use netbeans to manage my project, but I can't find a way to include the lib/ folder. Netbeans automatically creates a MANIFEST.MF file inside the application jar and also creates a folder called lib/ which includes all dependencies. This manifest specifies a Class-Path attribute that overrides any -cp argument provided on the command line. I can select an arbitrary folder in netbeans' library

maven add a local classes directory to module's classpath

亡梦爱人 提交于 2019-12-30 07:22:46
问题 I know this is a bit out of maven's scope, but I need to add a local directory with compiled classes to the module's classpath. I saw: Maven: add a folder or jar file into current classpath, but this is good for a jar only. I need to have a similar solution but with compiled classes in a directory on local file system. Is this even possible? Thx! 回答1: After some extensive research, I found that my best option was to use the maven-antrun-plugin and during the process-resources phase, generate

How to compile servlets from command prompt?

℡╲_俬逩灬. 提交于 2019-12-30 07:15:10
问题 I'd like to compile a very basic servlet from command prompt, but it is always unsuccessful and the compiler tells me the following: error: package javax.servlet does not exist. I googled for the solution and I found that I need to include the servlet.jar libraries into my PATH. I believe I did. I strongly believe that the location for those libraries in my computer is: C:\apache-tomcat-7.0.23\lib\servlet-api.jar\ and the end (the relevant part) of my PATH is the following: %JAVA_HOME%\bin;C:

How to read a directory from the runtime classpath?

∥☆過路亽.° 提交于 2019-12-30 05:58:48
问题 My Java application needs to be able to find a myconfig/ directory which will be bundled inside the same JAR: myjar.jar/ com/ me/ myproject/ ConfigLoader.java --> looks for myconfig/ directory and its contents myconfig/ conf-1.xml conf.properties ... etc. How do I actually go about reading this myconfig/ directory off the runtime classpath? I've done some research and it seems that the normal method of reading a file from the classpath doesn't work for directories : InputStream stream =

Hadoop HADOOP_CLASSPATH issues

倖福魔咒の 提交于 2019-12-30 02:25:29
问题 This question doesn't refer to distributing jars in the whole cluster for the workers to use them. It refers to specifying a number of additional libraries on the client machine. To be more specific: I'm trying to run the following command in order to retrieve the contents of a SequenceFile: /path/to/hadoop/script fs -text /path/in/HDFS/to/my/file It throws me this error: text: java.io.IOException: WritableName can't load class: util.io.DoubleArrayWritable I have a writable class called

importing external jar files

谁说胖子不能爱 提交于 2019-12-30 00:41:31
问题 I have written a Java code which imports an external jar file. How can I compile and run it on the command-line? Thanks in advance! 回答1: Compiling from the command-line: javac -cp path_to_jar1.jar:path_to_jar2.jar Example.java Running: java -cp .:path_to_jar1.jar:path_to_jar2.jar Example For Windows, use ; as a path-separator (instead of : ). 来源: https://stackoverflow.com/questions/4421730/importing-external-jar-files

How to walk through Java class resources?

可紊 提交于 2019-12-29 18:47:45
问题 I know we can do something like this: Class.class.getResourceAsStream("/com/youcompany/yourapp/module/someresource.conf") to read the files that are packaged within our jar file. I have googled it a lot and I am surely not using the proper terms; what I want to do is to list the available resources, something like this: Class.class.listResources("/com/yourcompany/yourapp") That should return a list of resources that are inside the package com.yourcompany.yourapp.* Is that possible? Any ideas

How to walk through Java class resources?

南笙酒味 提交于 2019-12-29 18:47:06
问题 I know we can do something like this: Class.class.getResourceAsStream("/com/youcompany/yourapp/module/someresource.conf") to read the files that are packaged within our jar file. I have googled it a lot and I am surely not using the proper terms; what I want to do is to list the available resources, something like this: Class.class.listResources("/com/yourcompany/yourapp") That should return a list of resources that are inside the package com.yourcompany.yourapp.* Is that possible? Any ideas