Problems on mac os x for java newbie

Hi

i have just started learning java and was really enjoying it until I hit some big obstacles on the mac.

I have been working through Rogers Cadenhead's book Java 2 in 21 Days (from Sams). His examples are only explained for PC and Linux.

To complete the current chapter I need to set up directory structures and declare them as packages at the beginning of my .java files. This does not work on a mac and I can't find out how to do it. His examples are that you would have (for example) a directory structure called org/cadenhead/ecommerce in the JDK folder on a PC, and then at the top of each .java file you would say package org.cadenhead.ecommerce; . Does anyone know how I can create a similar thing on the mac?

I have tried simply writing the required .java files and compiling them, without any reference to packages at all, just keeping everything in a separate directory. But then I get scary messages when I try to compile such as:

javac -Xlint:unchecked Storefront.java

Storefront.java:9: warning: [unchecked] unchecked call to add(E) as a member of the raw type java.util.LinkedList

catalog.add(it);

^

Storefront.java:21: warning: [unchecked] unchecked conversion

found: java.util.LinkedList

required: java.util.List<T>

Collections.sort(catalog);

^

Storefront.java:21: warning: [unchecked] unchecked method invocation: <T>sort(java.util.List<T>) in java.util.Collections is applied to (java.util.LinkedList)

Collections.sort(catalog);

^

3 warnings

I don't really know what to try next and would really appreciate any advice anyone can offer me to get me back on track. Many thanks.

[1733 byte] By [bullet3a] at [2007-10-3 4:00:19]
# 1

Actually OS/X is based on a BSD variety of unix and should be pretty close to the Linux examples.

The problem you mentioned doesn't seem to have anything to do with Mac.

It seems that the problem is that you're using a JDK1.5 compiler on 1.4 source code. My guess is that the book is a little old. Those warnings are basically telling you that you're not using the Generics stuff from JDK1.5. You can use the "-source 1.4" option to javac to make them go away for now. Or you can find a newer textbook that also covers generics.

By the way, it's kind of a bad thing to put your own source code in the main JDK directory. If the book is telling you to do that, ignore it. Create a directory for your own code and don't mix it up with standard distribution stuff.

paulcwa at 2007-7-14 21:59:20 > top of Java-index,Java Essentials,New To Java...