I have a folder called src. In this folder i have a jar file log4j-1.2.7 which contains packages. In the same folder src i have another package com.abc which has a file App.java When i compile this class it cannot access classes within the jar file.
structure is something like this
I am writing D:\>src\classes>javac com\abc\App.java
It's unable to find the classes in jar file
Joined: May 20, 2004
Could you please write the error message that you are recieving.
Joined: Aug 02, 2004
I think your problem may be twofold. Firstly the directory structure of your application; secondly your classpath.
Set up your application directory structure something like the following:
This is the conventional way of setting up a Java app.
Ensure the following directories are on your classpath:
If you're using an IDE then set the classpath in your IDE configuration. On the command line, you can specify the classpath as follows (ignoring the classes directory):
Or set the environment variable 'classpath' as follows:
Note that setting the classpath environment variable in a command window is only persistent as long as the command window is open (i.e. it doesn't change your system settings)
From the src directory, you should then be able to execute:
If successful the class file will appear in the same directory as App.java. To create the classes in your myapp\classes directory add "-d D:\java\myapp\classes" to the command line.
Just a note about Log4J: Log4J is a very well designed and easy to use logging API, but are you aware that Java 1.4 has its own logging API, very similar to Log4J, in the java.logging package?
Alternatively, if you don't want to mess around with fancy hierarchical directory structures just stick everything under the D:\src directory and make sure it's on the classpath.