Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

bobber205

macrumors 68020
Original poster
Nov 15, 2005
2,182
1
Oregon
I have used REALbasic for almost two years, so learning Java, although hard, shouldn't be to difficult.

I figure if I'm going to major in computer software and hardware engineering in college, I should at least get a head start in Java. ;)

Now here's my question. I got "Ground Up Java" off ebay. Great book. Easy to read.
But the instructions in it for setting up Java on my mini Mac aren't applying.

What should I do?
I can type in Terminal
"java -version"
and a bunch of data comes up.

So I know it's there.
What should I do? BTW I am planning on using Eclipse or Xcode, and I have installed the developer tools (that's why I have Xcode ;) )

Thanks.
 

jsw

Moderator emeritus
Mar 16, 2004
22,910
44
Andover, MA
Java 1.4.2 is pre-installed with Tiger, and Java 5.0 is available if you sign up as an ADC member (free).

Download Eclipse (or use Xcode, but I find Eclipse to be easier for pure Java development) and you're good to go, or simply run everything from the command line in Terminal.
 

jefhatfield

Retired
Jul 9, 2000
8,803
0
bobber205 said:
I have used REALbasic for almost two years, so learning Java, although hard, shouldn't be to difficult.

Thanks.

don't underestimate java...it's a very deep language and is unlike any other language out there...but you're on the right track if you want to be a software engineer and learn java

for hardware engineering, that's a completely different field but you may take an electrical engineering class and some higher math if you are software side, and take lots of the above if you are hardware side with some programming, and i hope your school let's you take java if you want to use it for credit towards a computer or electronic/electrical engineering degree
 

bobber205

macrumors 68020
Original poster
Nov 15, 2005
2,182
1
Oregon
My school I will be going to, Oregon Institute of Technology, has a special program for people wishing to do the dual-major.

In Xcode, how can I run the sample programs that came on a CD with my book?

Here are the files

Feel free to download them to see what I'm talking about. I want to be able to participate in the "example discussions" that are in my book.

Thanks! and keep the replies coming!
 

plinden

macrumors 601
Apr 8, 2004
4,029
142
bobber205 said:
I have used REALbasic for almost two years, so learning Java, although hard, shouldn't be to difficult.

I figure if I'm going to major in computer software and hardware engineering in college, I should at least get a head start in Java. ;)

Now here's my question. I got "Ground Up Java" off ebay. Great book. Easy to read.
But the instructions in it for setting up Java on my mini Mac aren't applying.

What should I do?
I can type in Terminal
"java -version"
and a bunch of data comes up.

So I know it's there.
What should I do? BTW I am planning on using Eclipse or Xcode, and I have installed the developer tools (that's why I have Xcode ;) )

Thanks.
Try using the command line first - first thing, write the simplest HelloWorld.java program. The file name must match the name of the class:
Code:
public class HelloWorld {
    static public void main(String[] args) {
        System.out.println("Hello World!");
    }
}

Compile using javac:
javac HelloWorld.java

If all goes well, you'll have HelloWorld.class in your directory.

Run using java:
java -cp . HelloWorld

Also, see what happens if you leave out "-cp ." - java won't find HelloWorld.class.

IDEs like Eclipse take a lot of the work out of your hands, but I really don't recommend using them until you're comfortable with compiling with the command line. You'll make many more mistakes that way, and will learn a lot from them.

To see the options available for java and javac, type:
java -help
javac -help
 

bobber205

macrumors 68020
Original poster
Nov 15, 2005
2,182
1
Oregon
BTW If I download Eclipse on my mini Mac 10.4.3 computer, do I need to download all the extra files (like the JDT and stuff like that):D
 

bobber205

macrumors 68020
Original poster
Nov 15, 2005
2,182
1
Oregon
This sound really bad, but I guess learning is learning...

Where do I put and save that code?
In my book there was a part that had me set up the "path", but I could never do that correctly.

I have a folder on my Desktop called Java Programming and that's where I want all my files to go. At least I think so.
 

jefhatfield

Retired
Jul 9, 2000
8,803
0
bobber205 said:
My school I will be going to, Oregon Institute of Technology, has a special program for people wishing to do the dual-major.

In Xcode, how can I run the sample programs that came on a CD with my book?

Here are the files

Feel free to download them to see what I'm talking about. I want to be able to participate in the "example discussions" that are in my book.

Thanks! and keep the replies coming!

i had a programming teacher, phd university of oregon in cs in programming languages, but he mainly teaches computer hardware repair (comptia a+ path) at the college, but he had to teach himself that from scratch...he also teaches java and vb, but hardware is his main gig...he's a very unusual person, right and left brained equally, and it makes him understand hardware and engineering, and coding/programming without missing a step

most programmers just don't get "real" engineering and higher math and vice versa...many a creative writer and artist make better programmers most of the time
 

bobber205

macrumors 68020
Original poster
Nov 15, 2005
2,182
1
Oregon
How do I set up the path for my Java programs.
I need to be able to do that before I can compile don't I?
 

jsw

Moderator emeritus
Mar 16, 2004
22,910
44
Andover, MA
bobber205 said:
How do I set up the path for my Java programs.
I need to be able to do that before I can compile don't I?
All the Java executables (javac, java, etc.) are already in your path, so they should work just fine if you just, say, use Terminal to go to your source directory.

Or use Eclipse, which works well.

Or Xcode, which i haven't been too successful using Java with so far...
 

bobber205

macrumors 68020
Original poster
Nov 15, 2005
2,182
1
Oregon
Where do I save the text file with the code in it? the .java file/.

I am EXTREMELY confused. A detailed explanation would be greatly appreciated. I will have to wait awhile, (maybe tomorrow), for Eclipse.

IT's 100 megs to download... And I have dialup. That's 12 hours or so.

If someone could explain me how to get properly started, I would be forever grateful.
 

portent

macrumors 6502a
Feb 17, 2004
623
2
This little app is a nice way to start off in Java...much simpler than the command line, or even Eclipse. It's basically an editor with a simple front-end for javac and the JVM.

http://homepage.mac.com/jmacmullin/

It's not very powerful, but its easy (and free.)
 

bobber205

macrumors 68020
Original poster
Nov 15, 2005
2,182
1
Oregon
I"ll use JJEdit until I get Eclipse.

Thanks so much! BTW Does anybody here use Eclipse for Java for when I need help?
 

jsw

Moderator emeritus
Mar 16, 2004
22,910
44
Andover, MA
bobber205 said:
I"ll use JJEdit until I get Eclipse.

Thanks so much! BTW Does anybody here use Eclipse for Java for when I need help?
I do. Sorry, been a bit busy tonight. I'll try to be of more help later on! Feel free to PM me with any questions.
 

jsw

Moderator emeritus
Mar 16, 2004
22,910
44
Andover, MA
bobber205 said:
BTW If I download Eclipse on my mini Mac 10.4.3 computer, do I need to download all the extra files (like the JDT and stuff like that):D
Nope - everything should be all set already under Tiger. BTW, Java 5.0 (aka 1.5) was released via Software Update today... I highly recommend getting it, as 5.0 has some fantastic new features, and you can still use previous Java techniques as well.
 

bobber205

macrumors 68020
Original poster
Nov 15, 2005
2,182
1
Oregon
Just thought you guys might want to know!

I just wrote from scratch my first Java program! YEAH! YEAH!

The only thing I don't like is each little app costs 6.9 megs of space to build... ???:eek:
 

plinden

macrumors 601
Apr 8, 2004
4,029
142
bobber205 said:
Just thought you guys might want to know!

I just wrote from scratch my first Java program! YEAH! YEAH!

The only thing I don't like is each little app costs 6.9 megs of space to build... ???:eek:

Sorry, haven't been keeping up with this, but WTF? You sure? What program did you compile, using what? HelloWorld.class is 426 bytes on my PC and on my Solaris workstation.

Can you give us the exact steps one-by-one that you did?

Even the mail web application I'm working on is only 8 MBytes when compiled.
 

bobber205

macrumors 68020
Original poster
Nov 15, 2005
2,182
1
Oregon
I should have given more information.

I am using XCode right now, and those files include a bunch of "build" files and stuff like that.
 

plinden

macrumors 601
Apr 8, 2004
4,029
142
Well, ok, but that's the reason I don't like IDEs - you get a bunch of stuff you know nothing about. If you're serious about Java, you'll have to learn how to set up your build environment yourself.

Anyway, when you do a release build and hand your programs off to be used, all the build stuff is not (or should not be) included.
 

bobber205

macrumors 68020
Original poster
Nov 15, 2005
2,182
1
Oregon
I'm noticing tons of stuff I have no idea what it is.

If I want to setup the build environment myself, can you point me to a site that explains how to do that from the ground up?
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.