Tom
Tom

Reputation: 911

Having trouble with java packages/setting classpath

I usually don't have any problems setting up the classpath and running programs, but I'm running into a bit of a problem. I'm working on a program that will download a series of reports. If the working directory is called Report downloader, my project resides in

src/org/report/reportdownloader

and the jar files I'm working with reside in

lib/

When I'm going to compile my project (I'm in windows :( ) I type in

javac -classpath .;..\..\..\..\..\lib.transfer.jar; ..\..\..\..\..\lib.someotherjar.jar; ReportGrabber.java ReportDriver.java

I get an error message saying

ReportDriver.java:12: error:package com.transfer does not exist
import com.transfer.*;
^
1 error

And I don't really understand why. I'm trying to import a valid package, and I showed it where to find the jar in the classpath and it's still giving me grief.

I'm losing my mind, I feel so dumb for asking about this. I could give up and just use eclipse but I really want to figure this out.

EDIT: When I type

java -cp .;..\..\..\..\lib\transfer.jar; ..\..\..\..\lib\someotherjar.jar; ReportDriver

to run the file, I get an error saying

Error: could not find or load main class ..\..\..\..\lib\someotherjar.jar;

Any ideas?

Upvotes: 0

Views: 89

Answers (2)

DwB
DwB

Reputation: 38300

Using a relative path seems like a bad idea to me.

Why not do this:

... -classpath /lib/transfer.jar /lib/someother.jar

or in windows:

... -classpath c:\lib\transfer.jar c:\lib\someother.jar

Upvotes: 0

Adel Boutros
Adel Boutros

Reputation: 10285

Why are there 5 .. instead of 4?

to access your lib directory from reportdownloader, you have to do

..\..\..\..\lib

not

..\..\..\..\..\lib

Upvotes: 2

Related Questions