Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Ryan Dowdy
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 3918
10
Chrome Fedora Hibernate
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch, Ryan Dowdy!

First use the correct syntax, It should be:
java -cp /home/rdowdy/dsc-tools/lib/tdifsyn.jar Driver
 
Ryan Dowdy
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 3918
10
Chrome Fedora Hibernate
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Glad you solved it, and nice to see your detail explanation on problems/solutions you encountered which might help someone else as well.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic