Skip to Main Content

Defining Java Classpath under MAC OS X

1012772Oct 1 2016 — edited Oct 2 2016

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.

Comments
Post Details
Added on Oct 1 2016
2 comments
2,937 views