aspose file tools*
The moose likes Beginning Java and the fly likes I Present a Simple Problem With Possibly A Simple Solution? On the topic of packages and .jar files. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "I Present a Simple Problem With Possibly A Simple Solution? On the topic of packages and .jar files." Watch "I Present a Simple Problem With Possibly A Simple Solution? On the topic of packages and .jar files." New topic
Author

I Present a Simple Problem With Possibly A Simple Solution? On the topic of packages and .jar files.

Ryan Dowdy
Greenhorn

Joined: Aug 03, 2011
Posts: 8
Hello!

I have come to this forum in need of help.

To provide a bit of background:

I have been tasked with writing tests for a large program with multiple classes. I've taken a year's worth of classes in Java.

With that said, I have had little experience dealing with packages, classpaths, etc as the work we did in my Java classes was based in an IDE so the package management was done for me.

Anyways I've been having problems getting my program to run correctly despite numerous attempts at the correct syntax. I am working from my computer on a remote server with Unix. Here is my current problem:




On a sidenote: I am unsure how to get the last two lines of the stacktrace to show.

Note that the "[null,null,0]" is input given to the program in order for it to test certain parameters on a method. It is my understanding that the "tdifsyn/CGenerator" signifies that the package doesn't exist in the classpath specified. However, I was able to get the program to compile using the same classpath. I believe the package, "tdifsyn" is stored in the "tdifsyn.jar" (it would make sense) however I am not the one who put that .jar file there in the first place.

If you need any other information, feel free to ask! I could post the Driver code up but its about 100 lines of code so I didn't think it would be appropriate.
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3775

Welcome to the Ranch, Ryan Dowdy!

First use the correct syntax, It should be:
java -cp /home/rdowdy/dsc-tools/lib/tdifsyn.jar Driver


SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
Ryan Dowdy
Greenhorn

Joined: Aug 03, 2011
Posts: 8
Vijitha Kumara wrote:Welcome to the Ranch, Ryan Dowdy!

First use the correct syntax, It should be:
java -cp /home/rdowdy/dsc-tools/lib/tdifsyn.jar Driver


Hello and thank you for your response! Although your response did not directly solve my problem, from it I was able to quickly realize what I had been doing wrong. By using the correct syntax you suggested, a different error had arisen suggesting that the Driver class itself could not be found. I had read from the Oracle site that to tell the JVM (?) to look in the current directory as well as the other specified one, I must include a "." in the classpath. So I ended up with this which still caused problems:

java -cp .;/home/rdowdy/dsc-tools/lib/tdifsyn.jar Driver

I had already tried this solution before, but I figured I would try again. However, this time I caught my silly mistake. Because I am working on a Unix system, using a semicolon inbetween directories is actually the incorrect syntax. The examples for setting the classpath on the Oracle website look to be using a command prompt (I think that's what its called?) instead of a Unix based shell (unsure of correct terminology here) which is probably what threw me off. So I changed it to this:

java -cp .:/home/rdowdy/dsc-tools/lib/tdifsyn.jar Driver

This worked! Thank you for pushing me in the right direction!
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3775

Glad you solved it, and nice to see your detail explanation on problems/solutions you encountered which might help someone else as well.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: I Present a Simple Problem With Possibly A Simple Solution? On the topic of packages and .jar files.
 
Similar Threads
Running java with a classpath on cygwin
Problem setting Environment Variable
Basic CLASSPATH problem on Mac OS X
ClassNotFoundException for MySQL
Running Javaflow