 |
 |
java newbie
|
 |
|
 |
|
Senior User
Join Date: Jan 2002
Location: Brisbane, Australia
Status:
Offline
|
|
Hi,
I have just started a new cource at uni. and were doing java...
The exercise is to make something when it is clicked on it will say hello world. I have seen an example specifically for macs that use system.out.println
however this book uses two specific .class files
1. ScreenWriter.class
2. KeyboardReader.class
Is there a way of getting these to work In Mac OS X?
The book we are using is Java: A framework for Programming and Problem Solfing (Kenneth A. Lambert Martin Osborne) 2nd
Should I just install Virtual PC and use Windows or should I be ok with Mac OS X?
|
|
|
| |
|
|
|
 |
|
 |
|
Clinically Insane
Join Date: Oct 2001
Location: San Diego, CA, USA
Status:
Offline
|
|
It should work the same on both Mac OS X and Windows, unless it's using some sort of platform-specific functionality (JNI or something), which would just be weird for something this simple. One of the big advantages of Java is that it works on any platform that has a Virtual Machine.
|
|
Chuck
___
"Instead of either 'multi-talented' or 'multitalented' use 'bisexual'."
|
| |
|
|
|
 |
|
 |
|
Senior User
Join Date: Jan 2002
Location: Brisbane, Australia
Status:
Offline
|
|
import TerminalIO.*;
public class JavaIsHot {
KeyboardReader reader = new KeyboardReader();
ScreenWriter writer = new ScreenWriter();
public void run() {
writer.println(" d ");
writer.println(" o l ");
writer.println(" l r ");
writer.println(" l o ");
writer.println(" e W ");
writer.println(" H ");
writer.println(" xxxxxxxxxxxxxxxxx ");
writer.println(" x x x ");
writer.println(" x Java x x ");
writer.println(" x xxxx ");
writer.println(" x is hot! x ");
writer.println(" x x ");
writer.println(" x x ");
writer.println(" xxxxxxxxxxxxxx ");
}
public static void main(String[] args)
{
JavaIsHot tpo = new JavaIsHot();
tpo.run();
}
}
Hmm I can't post it to look the same, it makes a coffee mug 
|
|
|
| |
|
|
|
 |
|
 |
|
Clinically Insane
Join Date: Oct 2001
Location: San Diego, CA, USA
Status:
Offline
|
|
I just tried that and it worked fine for me. Just make sure the TerminalIO package is in the same folder as JavaIsHot.class.
Oh, by the way, you can use the "code" tag for source code and it will look right. (Well, except with Objective-C, where you have to turn off the  smilies too. But that's another topic.)
(Last edited by Chuckit; Jul 22, 2003 at 04:35 AM.
)
|
|
Chuck
___
"Instead of either 'multi-talented' or 'multitalented' use 'bisexual'."
|
| |
|
|
|
 |
|
 |
|
Senior User
Join Date: Jan 2002
Location: Brisbane, Australia
Status:
Offline
|
|
Originally posted by Chuckit:
I just tried that and it worked fine for me. Just make sure the TerminalIO package is in the same folder as JavaIsHot.class.
Hmmm.
Let me just make sure of something, otherwise I could screw something up
What is the best way to write java. Should I use Text Edit?
Once I have mada JavaisHot.java  do I then go into termenal and type javac javaishot.java .
then what do i do ?
thanks for the help.
|
|
|
| |
|
|
|
 |
|
 |
|
Senior User
Join Date: Jan 2002
Location: Brisbane, Australia
Status:
Offline
|
|
LoL i can't get it to work

|
|
|
| |
|
|
|
 |
|
 |
|
Clinically Insane
Join Date: Oct 2001
Location: San Diego, CA, USA
Status:
Offline
|
|
Well, an IDE like ProjectBuilder or NetBeans would probably be the "best way to write Java." They have syntax highlighting and other nice features that come in handy when you're doing larger programs. But for little things like this, TextEdit and the Terminal are fine.
So yeah, once you have the file, you go into the Terminal and type javac JavaIsHot.java. Then, once you've got your class file, you type java JavaIsHot (note the lack of a .class extension--you just use the class name) and you should see the neat little coffee mug screen.
|
|
Chuck
___
"Instead of either 'multi-talented' or 'multitalented' use 'bisexual'."
|
| |
|
|
|
 |
|
 |
|
Senior User
Join Date: Jan 2002
Location: Brisbane, Australia
Status:
Offline
|
|
Originally posted by Chuckit:
(note the lack of a .class extension--you just use the class name)
Do'h !
Thanks very much. This is kinda cool  .
/me takes little babby steps with the help of his fellow mac users
|
|
|
| |
|
|
|
 |
|
 |
|
Senior User
Join Date: Jan 2002
Location: Brisbane, Australia
Status:
Offline
|
|
[source]d
o l
l r
l o
e W
H
xxxxxxxxxxxxxxxxx
x x x
x Java x x
x xxxx
x is hot! x
x x
x x
xxxxxxxxxxxxxx[/source]
|
|
|
| |
|
|
|
 |
|
 |
|
Clinically Insane
Join Date: Oct 2001
Location: San Diego, CA, USA
Status:
Offline
|
|
Excuse me; total mind-blank. The correct tag is "code." Don't know what I was thinking.
|
|
Chuck
___
"Instead of either 'multi-talented' or 'multitalented' use 'bisexual'."
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Dec 2001
Location: Atlanta, GA, USA
Status:
Offline
|
|
Originally posted by GlobalNomad:
What is the best way to write java. Should I use Text Edit?
BBEdit is a good option. Of course, it's not free. But it has some really nice features for java development.
Another free option (if your Mac is fast) is Eclipse. It's very nice, but a bit slow on my iBook/600.
|
|
Mac Pro 2x 2.66 GHz Dual core, Apple TV 160GB, two Windows XP PCs
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Oct 2001
Location: Umbrella Research Center
Status:
Offline
|
|
|
|
|
|
| |
|
|
|
 |
|
 |
|
Fresh-Faced Recruit
Join Date: Nov 1999
Location: San Jose, CA, USA
Status:
Offline
|
|
Originally posted by GlobalNomad:
What is the best way to write java. Should I use Text Edit?
I've used just about every Mac and pure Java IDE out there, and I have to say IntelliJ's IDEA is by far the best.
It costs money, but if you intend to do lots of serious Java devleopment, it's worth it.
http://www.intellij.com/idea/
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Aug 2001
Status:
Offline
|
|
Java programming in textedit is a fantastic way to get a headache. Use Eclipse if you can run it (it kicks extremely serious arse, and they're working on the performance), and Project Builder or one of the others if you can't.
|
|
|
| |
|
|
|
 |
|
 |
|
Senior User
Join Date: Dec 2002
Location: Portland, OR
Status:
Offline
|
|
Originally posted by jobim:
I've used just about every Mac and pure Java IDE out there, and I have to say IntelliJ's IDEA is by far the best.
It costs money, but if you intend to do lots of serious Java devleopment, it's worth it.
http://www.intellij.com/idea/
Agreed. The nicest thing about IDEA is that it is helpful when you want it, but not in your face when you don't. That said, I think Project Builder is a little more appropriate for an absolute beginner, because IDEs like IDEA and Eclipse will probably confuse with a lot of their terminology. Plus, it is easy to get reliant on a tool that does too much for you like a crutch.
I just tried out the new 3.0M2 version of Eclipse yesterday, I have to say that performance is very much improved in this release. I didn't use it long enough to tell how buggy it was but the performance almost seems up to the Windows version now.
Another good IDE for a beginner is jGrasp. I just went through a pair of classes on Java and this is the IDE they recommended. It doesn't do anything "for" you like the IDEs aimed at professionals, but it does make it easy for someone to simply type some code in an editor and get it to compile. It also has a halfway decent debugger that isn't overly complex for a beginner to use (unlike IDEAs debugger, which is way heavy on detail..) One word of warning though, it seems to freak out on OSX if you ever use a scroll wheel mouse.. it throws an exception and you have to relaunch it. You don't lose any data though. It's quick to launch, has a native OS X look-and-feel option, and runs as fast as a native app too.
EDIT: Forgot to mention, if you are a student, IDEA is only $99, which is great for such an awesome tool.
|
|
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |
|