On Aug 18, 6:52 am, Ian <[email protected]> wrote:
> Hello.  I tried posting a minute ago, but don't know what happened to
> it .... anyway
Please do not use an old thread to post your question. Open a new
thread and give it an accurate subject, this way later on everybody
may search for it.

>
> I am a Newbie to Java, as well as to my new MACbook Pro, with OS X
> 10.5 Leopard.  It has Java JDK pre-installed, although, it appears to
> be v 1.5.
Actually Mac OS X has Java 1.3, 1.4, Java 1.5 and Java 1.6 SDK
installed with variants for 32 bits and 64 bits eventually (if your
Mac is based on Intel architecture).
You may install the latest jdk for Mac OS X from the Apple Developer
Connections, just register (it is free), and access the Mac Dev
Center, log in, access the site and the Downloads section, then in
Java you may download it as well as its documentation.

The default jdk is Java 1.5, but you may change it if you want with
the Java Preferences application located in the Application/Utilities
folder. Just drag at the top of the list the jdk you want by default.
This preference is used when launching applets, and java web star
applications.

Now when you run some java code in the Terminal (command line front
end on Mac OS X), you need also to decide which java you want. To make
your choice permanent put in your .profile file in your user directory
(create the .profile eventually if it does not exist) the following:

export JAVA_HOME=$(/usr/libexec/java_home)

This is a switch which points to the runtime corresponding to the jdk
choosen in Java Preferences.

And the following line to get the path:

export PATH="$JAVA_HOME/bin:whicheveryouhaveinthe pathbefore"



> When I created the Hello project using NetBeans 6.7.1, as per the
> homework document, when I Open a new project, there is no "General" in
> "categories", and when selecting "Java Application",
This is a change in Netbeans, which has renamed General in Java
Application, nothing to worry about here.

> it creates
> the .Java as follows:
>
> /*
>  * To change this template, choose Tools | Templates
>  * and open the template in the editor.
>  */
>
> package hello;
>
> /**
>  *
>  * @author isundby
>  */
> public class Main {
>
>     /**
>      * @param args the command line arguments
>      */
>     public static void main(String[] args) {
>         // TODO code application logic here
>
>     }
>
> }
>
> As you can see, it created the "Package Hello" as opposed to the
> "Public class Hello..."
Yes, this is better pratice, not using the default package, but always
create a named package for your classes, hence new versions of
Netbeans give it to you for free.

It does not create the class Hello, because you have not changed the
default class which is Main when creating the application. Observe
carefully the last field of the dialog when you create an application,
it has by default:
nameofyourapp.Main

the first part will be the name of the package, which is derived by
default from the lowercase version of the name of your application,
and the second part will be the name of your class. You may change
both,  and generally speaking you have to change the latter.

>
> I know it's not a big deal, but I want to ensure that I learn Java
> appropriately based on the way this course is laid out.
>
> Is there something I'm doing wrong here, or does it have to do with
> the MAC JDK version in use here ?
You've not done anything wrong and you jdk version has nothing to do
with it, it is just a change in Netbeans version to promote best
practices.

Now if you want to change the jdk in Netbeans, use the Java Platform
menu inside Tools menu in Netbeans. You may add another version of
java here. To use it later, just change the version of jdk either when
creating the application or with the contextual Properties menu when
right-clicking on the package in the Projects tab in Netbeans.

If you want to have java 1.6 permanently as the jdk by default, you
have to change first the java preferences, then to install Netbeans,
as Netbeans automatically recognize as default jdk the one that is
specified in java preferences the first time you use it.


--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/javaprogrammingwithpassion?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to