Forum Stats

  • 3,723,347 Users
  • 2,244,533 Discussions
  • 7,850,424 Comments

Discussions

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Defining Java Classpath under MAC OS X

1012772
1012772 Member Posts: 4
edited October 2016 in Java 8 Questions

Hello,

I have to port Java applications from Windows to OS X,  but I'm pretty new to the MAC world, even to the UNIX world. So I apology if my question is too much trivial.

I've a lot of difficulties to define the classpath under OS X (El Capitan) under  which I have installed the last available version of Java 8.

Let me explain first my environment : :

Under my home folder I have defined 2 other sub-folders :

1) /jars which contains multiple jar files (that I' using frequently for different applications)

2) /Cinephil which contains only one jar file : "cinephil.jar". The Toto class is into the "cinephil" package 

Now let's see my concern :

I start a Terminal session and type :

java -cp ~/jars/*:~/Cinephil/cinephil.jar cinephil.Toto

In such a case I get a message saying : class Toto not found

Then I entered :

CD Cinephil
java -cp ~/jars/*:cinephil.jar cinephil.Toto

It works fine.

However if I redo the first try but with a different search order in classpath
java -cp ~/Cinephil/cinephil.jar:~/jars/* cinephil.Toto

The Toto class is well found, but no  class belonging to any jar from the Jars folder is found.

It seems to me that defining a second folder in the Classpath (-cp) is merely ignored.

Certainly I'm doing something wrong, but I have not found what  yet.

However, I'm wondering whether using twice (or more) the tilde character (~) is allowed ?

Note : Because I'm just in test mode (for moving Java applictions from Windows to MAc) for the moment I don't use the Export command for $CLASSPATH.

I hope my English is not too bad, and thanks a lot in advance for any advice.

Answers

Sign In or Register to comment.