• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Java Classpath on Mac (Leopard)

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Marshal
Posts: 79239
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Sheriff
Posts: 11343
Mac Safari Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic