Mac Issues with Java

juhani

macrumors member
Original poster
Ok, I'm just starting out with Java and even borrowed some books from the library and stuff and everything was all clear since I actually had to write the 'Hello Java' program. Namely, these books tell me that i should write the well-known 'hello java' script to some kind of text editor, then compile it, then run it and voila - enjoy. So I started to look what's inside my OS X and found developer tools. I intalled it, tried several programs to compile the stuff, failed and then found XCode. I chose new file, java (or something) and was pretty happy 'cause at last i could write the freakin' script. But when i finished, the 'compile' command was as inactive as it is possible to be! So why is it so :confused: ? Anyway I gave up, ran help and found out that new project would be much better choice to begin with a new program. But when i did it (chose a new project from the file menu) it showed me several options like Swing and many, many more that I can't recall at the moment. So what are they??? Which one should I choose and why :confused: ? And now the most disturbing matter. When i finally chose something that made absolutely no sense to me as none of those borrowed books had covered them (yet?), the computer created several files which already had scripts inside?!? Plus, there were many folders loaded with stuff inside that i did't expect to discover in the first place??? So here's my simple question: What the hell is going on??? Please help me, 'cause I'm really tired being such an ignorant fool and I don't want to ask those stupid questions any more.

Thanks in advance,
Juhani

PS. Maybe the problem is also with the books which (perhaps) expect me to use that freakin' Windows and don't tell me the stuff i need to know when using Mac. Isn't there any good Java book for beginners that also covers OS X? It was really strange and stupid that the library at Univerity of Glasgow didn't comprise almost any book related with Macs.
 

therevolution

macrumors 6502
May 12, 2003
468
0
Those books probably talk about compiling and running Java programs like this: (assuming you have a program saved to a file named HelloWorld.java)

Code:
javac HelloWorld.java
java HelloWorld
Is this similar to what your books say? If so, you can do this in OS X with Terminal. Go to /Applications/Utilities and open the "Terminal" program. Those commands will work there. You will need a basic understanding of how to operate in a UNIX environment. Many tutorials exist on the web; try Googling "unix tutorial" if you need this.
 

therevolution

macrumors 6502
May 12, 2003
468
0
I tried my best. Your post was rambling almost to the point of incoherency.

Next time, keep your question short and to the point. Try spacing it out a little more to make it less intimidating to read.

Also, when programming, you're often faced with "why doesn't this work" situations. Showing a little more initiative to figure it out on your own and telling us the results, rather than "OMG why isn't this working?!!!111," would probably have earned you more responses as well.
 

jeremy.king

macrumors 603
Jul 23, 2002
5,479
1
Fuquay Varina, NC
juhani said:
Please help me, 'cause I'm really tired being such an ignorant fool and I don't want to ask those stupid questions any more.
Perhaps a class or college course might help.

As for a book, look for books with command line examples to start. This will help you understand the ideas of compiling into bytecode (javac) and then running it (java). Assuming you have the JDK installed on your mac, these will be available using Terminal.

Or if you want the "easy" way out, download and install Eclipse and use that to run programs. It may be above your head (right now), however.
 

kettle

macrumors 65816
kingjr3 said:
By?

Its more popular than one might think - especially in embedded systems and JVM on a chip...
yeah, I wasn't meaning its usefulness, more the tit for tat Microsoft v Sun trying to trip each other up, generally making it a headache to use cross platform.

That was the last I was reading about it, some sort of legal crud messing things up for people.
 

jeremy.king

macrumors 603
Jul 23, 2002
5,479
1
Fuquay Varina, NC
kettle said:
yeah, I wasn't meaning its usefulness, more the tit for tat Microsoft v Sun trying to trip each other up, generally making it a headache to use cross platform.

That was the last I was reading about it, some sort of legal crud messing things up for people.
We'll I'll assure you, disputes aside (which have been ongoing for years), Java isn't going anywhere. Sun will tank before Java, since it has quite the following and Big Blue waiting to gobble it up...That is, unless Ruby takes off...
 

juhani

macrumors member
Original poster
kingjr3 said:
Perhaps a class or college course might help.

As for a book, look for books with command line examples to start. This will help you understand the ideas of compiling into bytecode (javac) and then running it (java). Assuming you have the JDK installed on your mac, these will be available using Terminal.

Or if you want the "easy" way out, download and install Eclipse and use that to run programs. It may be above your head (right now), however.
Well actually I am planning to go to university next year to study IT and although they don't expect me to know Java or any other programming language I'm still very eager to get started by myself.

And I don't want an easy way out! I'd like to understand the core of the programming and for example why am I doing something when I'm doing it and so on. Not just enter the code and press buttons. So I think I'm going to work with Terminal for a while before taking up XCode or something else. It's just.. when, for example, I enter open Hello.java then the system still opens the file in XCode. Isn't it possible to do everything in Terminal?
 

jeremy.king

macrumors 603
Jul 23, 2002
5,479
1
Fuquay Varina, NC
An uber geek might say use vi to edit your files.

I would suggest you change the application associated with .java files. You can do this in the Get Info window on the file.

SubEthaEdit is a good text editor amongst others.
 

mwpeters8182

macrumors 6502
Apr 16, 2003
411
0
Boston, MA
I wouldn't suggest VI for someone new to the programming game - unless you're the type that does everything in the terminal. Go for textwrangler, from the same folks who make BBEdit. It does syntax highlighting, and isn't a resource hog.

<MP>
 

netytan

macrumors 6502
May 23, 2004
254
0
kingjr3 said:
We'll I'll assure you, disputes aside (which have been ongoing for years), Java isn't going anywhere. Sun will tank before Java, since it has quite the following and Big Blue waiting to gobble it up...That is, unless Ruby takes off...
I agree that Java isn't going anywhere just yet but it is loosing a lot of ground to M$.NET.

Personally I try to stay away from anything M$ has touched but since C# is becoming the first language taught in education it's getting harder to avoid.

Luckily there is an Open source alternative: Mono. But I'm not sure about the state of play when it comes to making Cocoa applications with C#. I'm sure there's a way.

Mark.
 

DavidLeblond

macrumors 68020
Jan 6, 2004
2,197
286
Raleigh, NC
kingjr3 said:
Perhaps a class or college course might help.

As for a book, look for books with command line examples to start. This will help you understand the ideas of compiling into bytecode (javac) and then running it (java). Assuming you have the JDK installed on your mac, these will be available using Terminal.

Or if you want the "easy" way out, download and install Eclipse and use that to run programs. It may be above your head (right now), however.
I gotta support his plug for Eclipse. That is the only tool I ever use to do my Java coding in. I don't see it as being the "easy way out" though. When you get further along in your programming, you're going to want a debugger.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.