• Post Reply Bookmark Topic Watch Topic
  • New Topic

Java Classpath on Mac (Leopard)  RSS feed

 
Paul Maxfield
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello everyone, I'm hoping that someone can help me with my little problem. I new to Java and somewhat new to the Mac platform. I'm learning Java through the (Sams Teach yourself Java 6 in 21 days)I'm on day 6: Packages, Interfaces, and Other Class Features, and I'm trying to understand the Java Classpath. If someone could tell me how you go about doing this on a Mac I would be most greatful. I'm running all my Java applications from the terminal and not an IDE.
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Paul,

Welcome to the ranch.
You might find this useful.
http://lists.apple.com/archives/Java-dev/2007/Aug/msg00436.html
 
Campbell Ritchie
Marshal
Posts: 56220
171
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to JavaRanch

What version of Java are you running? you should be able to find that from the command line by writing

java -version
javac -version

and the answer to both ought to be more-or-less the same. You don't have to do anything with your CLASSPATH for recent versions of Java on PCs (neither on Windows nor on *nix), so you probably don't have to set a CLASSPATH on a Mac either. You may need CLASSPATH options when you start using large applications, but then you set the CLASSPATH at the command line.

I found this by googling; I hope it is of some use; if you need more information don't hesitate to ask again.

And have a look at our Mac forum because there might be something useful there.
 
Paul Maxfield
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks everyone, and thank you for the links, I've looked at the "IBM" link and tried it out, but ran into an "xlint" error I guess you could call it that. I'm getting the message:

Storefront.java uses unchecked or unsafe operations. Recompile with -Xlint:unchecked for details.

Now to recompile with "no lint" (sorry couldn't resist) do I need to add this to the source file or is this something I add to the javac command?
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That message is not an error, just a warning. It's safe to ignore it until later, when you know what it means and how to deal with it.
 
Paul Maxfield
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, hello everyone again

First just wanted to say thank you to everyone, I've made some head way with my problem, but I've run into another one regarding the same topic.

Ok here it goes, this app I'm working on draws on two classes that I have created in a custom package called (org.cadenhead.ecommerce). I created my package directory as follows:

main Java folder is called (J21work), package folder is called (giftstore), in giftstore I have (bin) & (src), I created my java files in (src) and compiled the first by doing "javac -d bin src/org/cadenhead/ecommerce/Item.java" all went well.

The second one I compiled by doing: "javac -d bin -sourcepath src src/org/cadenhead/ecommerce/Storefront.java" again all went well.

Now I'm trying to compile the app portion (I guess you'd call it that) called (GiftShop)which is located in (J21work/temp) and I'm not having any luck, I keep getting an error message saying that my package (org.cadenhead.ecommerce) doesn't exist.

Each of my class files have (package org.cadenhead.ecommerce) in them and in the main class (GiftShop) I do have the (import org.cadenhed.ecommerce).

I have an idea, but before I go and try it, I wanted some input from more experienced people. My idea is, since I have the two supporting class files in (giftstore) I should have written the package and import as (package giftstore.org.cadenhead.ecommerce) & (import giftstore.org.cadenhead.ecommerce).

Am I on the right track, or am I still missing the boat
[ September 27, 2008: Message edited by: Paul Maxfield ]
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So your current directory (the one from which you're compiling) is J21work/temp, right? In that case, the relative path to your package org.cadenhead.ecommerce is up one level (to J21work) and then in bin." So try adding the classpath flag -cp ../bin to your compilation command. (Note: The double dots (..) should bring you up a level.)

Edit: Whoops. I missed the "temp" part when I first replied.
[ September 27, 2008: Message edited by: marc weber ]
 
Paul Maxfield
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sorry Marc I don't get it

My file structure looks like this:

users/paulmaxfield/J21work/giftstore
from (giftstore) I have src/org/cadenhead/ecommerce (which has the 3 .java files of "item","storefront","giftshop"

I've managed to compile both item, and storefront into the bin folder of giftstore, (but I'm trying to compile "giftshop.java" into temp witch is located in users/paulmaxfield/j21work/temp (I'm going on the recommendation of the book I'm studying out of that says that it may not work if I try to compile this app in the same bin folder that holds the two support classes)

So I'm trying to figure out the "javac" command that compiles the GiftShop into the "temp" folder. Then I'm trying to figure out the "Java" command that will run this thing.

sorry, programming is just really new for me. I understand what you're saying with the ../ I just don't get how to put it all together
 
Paul Maxfield
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well I figured it out, again, thank you everyone who provided input on this post, it was very much appreciated.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!