PDA

View Full Version : Compiling & Running Java? (on OS X)


MagSafe
2006-05-04, 13:28
Hey :),

I've been using Textpad (http://www.textpad.com/) to compile and run Java on my old (and retired) Windows laptop, but since I rarely even switch it on these days I'd like to continue this by starting to compile and run Java on my mac.

With Textpad I used to write a java file and press CTRL+1 to compile, then CTRL+2 to run the Java application ... I was wondering if there was a similar way of doing this on a mac?

I understand that J2SE is already installed into OS X, I just need a program that will be able to compile and run my java code. I already use BBEdit to type up my html and php code but as far as I can see it doesn't have any way of compiling and running Java applications on it.

Thanks for any help given,

Steven.

Blue Light Bandit
2006-05-04, 13:33
From the command line, you compile Java source for Mac OS X just like you do for any other operating system:

javac classname.java

And to run it:

java classname

Is what you're asking if there's a way to make that happen within your editor of choice (BBEdit)?

colivigan
2006-05-04, 13:58
Although I generally despise them, you might want to look at an IDE (http://en.wikipedia.org/wiki/Integrated_development_environment) like Eclipse (http://www.eclipse.org/downloads/), especially if you're not terribly comfortable on the command line.

chucker
2006-05-04, 13:59
In TextMate, in a Java class, hit Cmd-B for "Build and Run single file".

MagSafe
2006-05-04, 14:06
From the command line, you compile Java source for Mac OS X just like you do for any other operating system:

javac classname.java

And to run it:

java classname

Is what you're asking if there's a way to make that happen within your editor of choice (BBEdit)?

Hi,

...I didn't realise you could run it from the terminal actually, like you do with Windows.

It would probably be quicker to just run it straight from BBEdit though...If I had a choice, do I?

bassplayinMacFiend
2006-05-04, 14:14
You may be able to put together an Automator function or an AppleScript. I don't think BBEdit has this functionality out of the box though. I tried searching on 'Java' on the BBEdit FAQ list and came back with no hits.

MagSafe
2006-05-06, 09:39
Just to let you know I've downloaded the 30 day trial of TextMate and it works brilliantly with my Java files :)

...After the 30 days I will most definetly be buying a full licence :)

Thanks for the help,

Steven.