classpath « Development « Java I/O Q&A





1. How to configure Caucho Resin's Java classpath to the system's library directory    stackoverflow.com

I have a folder, '/var/unity/conf' with some properties files in it, and I'd like the Caucho's Resin JVM to have that directory on the classpath. What is the best way to modifiy ...

2. how can i get javac to search child directories of classpath?    stackoverflow.com

I have 3 files: /a/A.java /a/aa/AA.java /b/B.java and B.java depends on A.java and AA.java. I basically want javac -classpath /a /b/B.java to work (i.e. have javac search below /a). Is there any way I can do this? ...

3. How best to add UNC file paths to a Java Classpath    stackoverflow.com

Using Java (1.4) is there a way in which to use Windows UNC file locations (\\servername\filestore\etc) within the classpath?

4. adding relative directory to java classpath and using ClassLoader().getResourceAsStream("")    stackoverflow.com

Is it possible to add a relative directory (ie, foo/bar/plugh) to the java classpath and use

InputStream in = getClassLoader().getResourceAsStream("xyzzy.properties");
To fetch foo/bar/plugh/xyzzy.properties? My classpath looks like this:
foo.jar;foo/bar/plugh;xyz.jar
And I am able to use ...

5. Adding files to java classpath at runtime    stackoverflow.com

Is it possible to add a file (not necessarily a jar file) to java classpath at runtime. Specifically, the file already is present in the classpath, what I want is whether I ...

6. How do I put the entire lib directory (including all subdirectories) on the classpath using Ant?    stackoverflow.com

I'm not sure this is the problem, but it looks like it might be the case. I'm getting build errors telling me that certain packages don't exist. These packages are packages ...

7. help with ant file - classpath for Java task    stackoverflow.com

I have the below build file for Ant and trying to use the target 'run' for executing the program.

<property name="springjar"   location="E:/Tools/spring-30/dist/" />
<property name="logjar"     location="E:/Tools/commons-logging-1.1.1/" />

<patternset ...

8. How can I find a package?    stackoverflow.com

In my code I have the following statement import com.apple.dnssd.*; and compiler (javac) complains about this line. It writes that the package does not exist. But I think that it could ...

9. How do I compile a Java application that uses Apache Commons IO at the command line    stackoverflow.com

I made an application in NetBeans and I used the Apache Commons IO jar file. The application works fine in NetBeans, but I want to be able to compile it ...





10. Problem locating file in a classpath    stackoverflow.com

I'm trying to read in file content, ex :

public void myMethod(){
     FileInputStream fstream = new FileInputStream(fileLocation);
           // ...

11. How can I find the installation directory of a Java application?    stackoverflow.com

I need to find the installation directory of a Java application. I will use it to find recourses that are not on the classpath. What is the best solution for it? ...

12. how to load/reference a file as a File instance from the classpath    stackoverflow.com

i have a file that is in my classpath. for example, com/path/to/file.txt. i need to load or reference this file as a java.io.File object. the reason is because i need to ...

13. Using bash, how do you make a classpath out of all files in a directory    stackoverflow.com

This will be a really simple freebie for a bash guru: Question Using bash, how do you make a classpath out of all files in a directory?


Details Given a directory:
LIB=/path/to/project/dir/lib
that contains nothing but *.jar ...

14. How to execute Java program from parent directory    stackoverflow.com

I have a directory structure like this:

./
 +-- myClass
 |   +-- MainClass.class
 |
 +-- dummy
     +-- DummyClass.class
MainClass contains the public static void main(String args[]) and ...

15. Loading a configuration file from the classpath    stackoverflow.com

I'm working on making my Java app easy to deploy to other computers and am writing an ant script to do so, that is going fine. I'm having trouble loading resources that ...

16. set classpath other directory in the hierarchy    stackoverflow.com

there are two directories C:\a\b C:\a\c well iam in say directory c:\a\b when i do a set classpath=%cd% the directory C:\a\b gets assigned to the classpath variable but i want to assign C:\a\c to classpath How can ...





17. how does java deserialize an object whose class isn't on the classpath but whose superclass is?    stackoverflow.com

Say I have class Foo that extends Bar. I create an instance of Foo and serialize it to a file. Some other code reads that file and attempts to recreate the ...

18. How to compile java file which calls MeCab - Japanese part-of-speech & morphological analyzer?    stackoverflow.com

I'm trying to use MeCab (http://mecab.sourceforge.net/#download) to do the word segmentation of Japanese sentences as well to tag every word by part of speech. I installed MeCab by following these instructions ...

19. Unix shell: Turn file with directory names to ':' separated classpath    stackoverflow.com

I use Java5 and I don't want to point each .jar file in Classpath so I've tried to write small shell script:

find $LIB_DIR -name '*.jar' -print > /tmp/classpath
CP= 
cat /tmp/classpath | ...

20. Running Java Program in Sub-Directory    stackoverflow.com

Please give suggestions if my formatting is wrong, this is my first time posting a question here. Using UNIX, I'm having trouble running a Java program 'Master' (located in a ...

21. Compiling without having to put project files under classpath    stackoverflow.com

I want someone to be able to compile the code without then having to set the CLASSPATH to the project directory. Is this possible?

22. Shell file works when run manually but fails when run in CRON    stackoverflow.com

I have a shell file (compile.sh) that compiles then runs a java program. It works when I run it manually on an AIX server but gives me an error when ...

23. issue with classpath set with current application source file in javax.tools.JavaCompiler?    stackoverflow.com

I have condition on web application where I am upload a .java source file and compiling this source based on the dependencies with jar files resides in WEB-INF/lib folder. I am able ...

24. Can a directory be added to the class path at runtime?    stackoverflow.com

In order to better understand how things works in Java, I'd like to know if I can dynamically add, at runtime, a directory to the class path. For example, if I launch ...

25. Getting absolute path of a file loaded via classpath    stackoverflow.com

I have this very specific need wherein a file is loaded from classpath and the same is used in another module which needs it's absolute path. What are the possible ways ...

26. determining size of a file from classpath ???    coderanch.com

I have to determine the length of the file present in the classpath to populate a byte array. On reading from the classpath I get an InputStream and there is no method which exposes size of the file. Iam currently doing something like this, InputStream inputStream = this.getClass().getResourceAsStream("/my.txt"); byte[] fileContents = new byte[100]; try { int read = inputStream.read(fileContents); // byte[] ...

27. simple search v/s classpath search    coderanch.com

28. Reading files from classpath searching with a pattern    coderanch.com

Hello, I want to read a file zipped in a jar and loaded through the jar into the classpath. The problem is that I want to find several files loaded in the classpath giving a pattern for example *text.xml. This pattern should lead to a result like follows: com.company.test1.test.xml com.company.test2.test.xml and so on... Is there a possibility to implement such a ...

29. Write Classpath as a seperate file    coderanch.com

I am placing my jar files on WEB-INF/lib/ directory. But it ask for classpath. It asks whether the jar files is in path or not. So, i need to write Classpath file. How to write it as a seperate file. So it can be submitted on remote host. And it automatically detected. My host server is resin . Can anyone have ...

30. Classpath, lib directory, and lots of libraries!    coderanch.com

I'm working on a current project that requires a long list of third party library jar files. Currently I have placed them all in a lib directory. I currently have a bat file that looks a little something like: java -cp .;lib\library1.jar;lib\library2.jar;lib\library3.jar;lib\library4.jar and so on. I find this pretty ugly and I don't like having to edit this file as I ...

31. Reflection on files already on the classpath    coderanch.com

Hi everyone. I am doing a little application for executing classes dynamically. I'm already able to test it by loading one class at the time to the classpath at runtime, but now I have to do it by loading all those classes from a JAR. I have my .class files on a .jar, which is successfully loaded to the classpath at ...

32. why include directory in classpath ?    coderanch.com

If you want to be able to load classes not in a JAR file, but stored as *.class files in that directory, you have to put the directory in the classpath. Note that if the classes are in a package, you'll have to add the base directory of the package to the classpath.

33. Packages, directory structures, javac -d and CLASSPATH    coderanch.com

OK, after doing some major brainstorming, researching, reading and testing, I'd like to get a confirmation on whether I'm using all of the things in the Subject line correctly (I'm running Windows 2000, BTW): 2 source files: //First src file saved as Test.java package testPackage; public class Test {...} //Second src file saved as TestingTest.java import testPackage.*; public class TestingTest extends ...

34. put directory in classpath    coderanch.com

hi no. there is no way to just put the directory in the classpath. u can probably write a loop in the script (.bat on windows and shell script on unix/linux) to do that for u... i usually write following loop to include every jar file in the classpath for i in `ls $HOME/jars/*.jar` do CLASSPATH=$CLASSPATH:$i done export CLASSPATH javac *.java ...

35. Classpath file    coderanch.com

Hi there! I have a propertie file that I load to find out which hibernate.cfg.xml should I read. This file is located under my project root folder, and after deployed under the EAR root folder. The class that reads it, is located in a package com.mycompany.persistence.util. I'd like to read this file using a relative path, is it possible? like properties.load("/mypropertie.properties"); ...

36. Adding files....dynamically. to the classpath.    coderanch.com

Hi, Suppose we have a application accessing a properties file and the JVM starts and application starts using the properties file... Now i want to modify the properties file ... Does this require the restart of the application.. Are there any features like hot deployment of applications in servers which would allow me to dynamically access the modified version as the ...

37. Setting classpath to compile .java files    coderanch.com

I can't seem to be able to compile any .java files yet because they're somehow not being found. Javac is being recognized as a command, just to get that out of the way. I am, to the best of my knowledge, setting the classpath correctly (not confusing PATH with classpath) and putting my .java files in my intended directories. Do the ...

39. classpath file pick order    coderanch.com

Hi, I have a classpath issue. My app folder is C:/agent I have src packages that start with com.abc and also few config files under my app folder. I have archived them as agent.jar so that compiled classes in com.abc package and files under config folder are archived into agent.jar. Therefore the folder structure is something like following:- C:\agent | | ...

40. Problems setting classpath    coderanch.com

FileInputStream doesn't look on the classpath for the file it open. In the first case, you provide a relative path, so it looks in the current working directory. (Probably eclipse when you're testing.) In the second example, you provide an absolute path, so it will look for the file exactly there in a directory called resources off your root directory. You ...

41. getting a randomly generate directory onto the classpath    coderanch.com

My code accepts a zip file as input. I unpack several images from the zip file into a temp directory (literally, created by File.createTempFile()) I have another program that will load these images as resources and put them into the database *if* I can get the temp directory onto the class path. If I can do this I won't have to ...

42. Loading a file from classpath    coderanch.com

43. Are pathname relative to actual code location (versus possibilities in classpath) ?    coderanch.com

I have the following file layout (your typical eclipse layout) : project --images -----img.png --bin ----pkg1 ------Main.class ----pkg2 ------ImageLoader.class Now image ImageLoader loads an image using the path "images/img.png". This will run fine in eclipse, but I'd like to be able to run this code via the command line without breaking eclipse compatibility. It seems that using something like "java pkg1/Main" ...

44. Problems with the java command and -classpath concerning the current (.) directory    coderanch.com

Hi, attached please find a screenshot of my different commands (java versus java -xlasspath) - so you can see what the exact error message is. I run the java command from the dev directory, and x is a valid subdirectory of dev. My OS is Windows Vista, and as I've written, I use Cygwin in order to emulate Unix. Same problem ...

45. Classpath or How to declare files    coderanch.com

Hi, My application has a command line interface and it is packaged into a .jar file. In my application, I use Log4J for logging. I have placed the log4j.xml at the same directory where the .jar file is kept and it works fine. D:\Development\Filehandler\dist\... But, when I call the .jar file from some other directory, for ex: C:\, it throws error ...

46. classpath and 'current directory'    coderanch.com

47. Config files in a classpath ?    coderanch.com

Hi guys : I always assumed that the classpath was for adding jar files. However, I recently inherited a project where .properties files are supposed to be in the classpath, for the project to execute . Im wondering --- is there something about the classpath that i dont understand ? I assumed it was for precompiled java binary dependencies , like ...

48. Reading a .der (file generated by openssl rsageberate command) file from classpath    coderanch.com

Hi, I need to read the private key from the .der file generated by openssl rsagen command. I am reading the file in the junit test case using the following piece of code, but the assertnotnull(privateKey ) is returning null, that means the private key is not read from the file. Need urgent help. /** * */ package com.entrib.emg.server.controller; import java.io.FileInputStream; ...

49. Classpath problem for current directory    java-forums.org

I am working in a directory called c:\j21work. I created a class file called PrimeFinder.class that contains a class definition and another class file called PrimeThreads.class which contains a class and main() method. I am receiving the error: Exception in thread "main" java.lang.NoClassDefFoundError: PrimeThreads/java After researching it, this is apparently due to needing the specify that the current path be used ...

50. read files from classpath    forums.oracle.com

51. How to get the file from classpath?    forums.oracle.com

To get a resource from the classpath use [Class.getResource()|http://java.sun.com/javase/6/docs/api/java/lang/Class.html#getResource(java.lang.String)] (or getResourceAsStream()) or [ClassLoader.getResource()|http://java.sun.com/javase/6/docs/api/java/lang/ClassLoader.html#getResource(java.lang.String)]. Note that you won't get a File object this way, because resource on the classpath need not be classes (for example: .class files stored in a .jar are not files in the sense that the OS can access them directly, the same is true for classes accessed via ...

52. Open or edit .classpath file?    forums.oracle.com

53. Problems with classpath and accessing a specific file    forums.oracle.com

Solution depends on whether the files will be in the jar or not. But the general idea is the same. A class has a location where the location can be specifically identified by using the class loader of the class (method on the class) to get the 'resource' location. That allows you to identify a root for the jar file and ...

54. Open File from location on classpath    forums.oracle.com

Hi, My web application contains a text file that is located in a config folder on the classpath. During processing I need to access this file using the File class. Presumably I need to specify the URI of this file to open it. How do I obtain this URI though? Is it through the ClassLoader.getResource("filename.txt") method? Thanks.

55. How to execute file using classpath?    forums.oracle.com

2nd method I used is System.getProperty("user.dir") to determine to find the relative path. It works but with minor problem. I found out that method returns the path in OS specific ways (like backslash based path in windows) which I ran into problem whether to use "/" or "\" in my code to further extend my path.

56. classpath for package in .java file    forums.oracle.com

57. Write / Read Files in ClassPath    forums.oracle.com

Hello Everyone... I'm a beginner to Java Technology. I'm developing a project that needs to write and read files. Since, I have build my project into a JAR file, when I get the CLASSPATH value, the jar file's name is returned. I don't know how to get the absolute path where the JAR file is located. For example, If my JAR ...

58. referencing files from classpath    forums.oracle.com

59. adding a folder(containing configuration files) in classpath    forums.oracle.com

I have some folder containing few property files.We use websphere as our application server.In order for application to access this folder containing properties file I have two options 1)create a websphere environment variable and define the folder there.In my application I use the environment variable to get hold of the properties file. 2)add this folder to websphere class path and my ...