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

jcgnu

macrumors regular
Original poster
Dec 30, 2006
113
0
Hello everyone.

I've been a Windows user for like ages... I recently switched to Mac and I have a little problem over here that I hope someone will be so kind to help me out with.

Lately, I've been using Netbeans for Java development. It works great, although everytime I want to create a java file, I need to create a whole project thing. It is sometimes useful to create a project, but sometimes I just want to create a single file and compile it (and run it, of course) and that's something you CAN'T do with Netbeans.

Back in Windows, I used a program called JCreator, which is free, to do this kind of stuff, and only when I wanted to create a whole project I used Netbeans.

Problem is, there's no Mac version of JCreator. Does anyone know a program that'll let me do that? I mean, to create, edit (with colors and stuff), compile and run Java programs... The more similar it is to JCreator the better... I hope it's free, as well...

Anyway, thanks for the help.

JC
 

Heath

macrumors regular
Aug 19, 2005
133
0
Canada
JEdit, Textwrangler, to name a couple.
I use textwrangler on OS X and JEdit everywhere else.
 

RaceTripper

macrumors 68030
May 29, 2007
2,867
178
See the OP. Eclipse has the same problem that Netbeans does. It's project based. You can't just create a single Java source file to compile and run. I use eclipse too, but it's not the answer to the OP.

I use TextMate when I want to create a quick and dirty Java program to run.
 

jcgnu

macrumors regular
Original poster
Dec 30, 2006
113
0
Thanks a lot for your responses.

Out of the three suggested apps (except Eclipse), I liked TextWrangler a little better.

Now my problem is I don't really know how to do anything with it LOL.

1. How can I compile a program without running it??

2. I try to run a program and I get a message saying "This file doesn’t appear to contain a valid ‘shebang’ line (application error code: 13304)".

Thanks for the help!
 

RaceTripper

macrumors 68030
May 29, 2007
2,867
178
Thanks a lot for your responses.

Out of the three suggested apps (except Eclipse), I liked TextWrangler a little better.

Now my problem is I don't really know how to do anything with it LOL.

1. How can I compile a program without running it??

2. I try to run a program and I get a message saying "This file doesn’t appear to contain a valid ‘shebang’ line (application error code: 13304)".

Thanks for the help!

To compile:
javac <java source filename>
To run:
java <name of java class with main method>

You cannot run a java program without compiling it first. The above commands are what you would use in a shell. How you do it within an editor depends on the editor.
 

jcgnu

macrumors regular
Original poster
Dec 30, 2006
113
0
To compile:
javac <java source filename>
To run:
java <name of java class with main method>

You cannot run a java program without compiling it first. The above commands are what you would use in a shell. How you do it within an editor depends on the editor.

Well, that's obvious dude...

I want to know how to do it within TextWrangler... and how to COMPILE without RUNNING, not all the way around (which is of course impossible)
 

jcgnu

macrumors regular
Original poster
Dec 30, 2006
113
0
No reason to get rude about it. You didn't say what your Java experience is. Forget I tried to help.

Unsubscribing...


Rude?? I wasn't trying to be rude, I'm sorry...

The problem is, you misread the thread. I was just stating that compiling is obviously necessary for running... And that I wanted to know how to compile and run within TextWrangler, which was stated in my previous post.

Anyway, thanks for the help, and you shouldn't be getting angry... That wasn't my purpose.
 

Cromulent

macrumors 604
Oct 2, 2006
6,802
1,096
The Land of Hope and Glory
Rude?? I wasn't trying to be rude, I'm sorry...

The problem is, you misread the thread. I was just stating that compiling is obviously necessary for running... And that I wanted to know how to compile and run within TextWrangler, which was stated in my previous post.

Anyway, thanks for the help, and you shouldn't be getting angry... That wasn't my purpose.

You can't. Textwrangler is just a text editor. It has no built in function for compiling etc.

You would need to use the Terminal. Although you could write a shell script or an Applescript to do it automatically I think.
 

jcgnu

macrumors regular
Original poster
Dec 30, 2006
113
0
You can't. Textwrangler is just a text editor. It has no built in function for compiling etc.

You would need to use the Terminal. Although you could write a shell script or an Applescript to do it automatically I think.

Ohh, OK, that's too bad... Anyway, do you know any other program that'll do the trick?? Compiling and running within it?? Perhaps JEdit???

Thanks!
 

numero

macrumors regular
Jul 23, 2002
106
3
OR
I'm a little confused. It seems like you want the features of an IDE (edit, compile and run), but you don't want to create a project. I wish I could run JCreator to see what it is that you are looking for.

My best suggestion for a light weight project is to use Xcode. Create a java project and then select "java tool" as the specific type. That will give you one .java file that will run "hello world" by typing command-r. This is what I did when I was in school.

It sounds to me that you are just wanting to try quick ideas. If you really hate creating projects that much you can even keep this one project around and just change your .java file every time you are trying out a new idea.

Xcode fits your price too -- free. Look on your OS installation DVD or get it from Apple's web site.

Hope this helps.
 

RaceTripper

macrumors 68030
May 29, 2007
2,867
178
I'm a little confused. It seems like you want the features of an IDE (edit, compile and run), but you don't want to create a project. I wish I could run JCreator to see what it is that you are looking for.
That's not an unusual feature. On the Mac TextMate has it (or you can run an Ant target). I'll bet BBEdit has it too. On Windows a lot of editors offer a quick compile and run: Textpad, JEdit (can use on Mac too), UltraEdit, etc.

I usually just use whatever text editor is handy, and compile/run from a bash shell if it's just a quick and dirty single Java class with no package or dependencies. But I also use Eclipse's "Scrapbook Page" for running snippets of code to test/try things.

But if I already have a project, I like to create a class with some code and create a JUnit test to execute it. That way, if it's something I keep and use, I already have a unit test for it.
 

myawn

macrumors member
Nov 9, 2006
52
3
Marietta, GA
I still say Eclipse . . .

You don't have to create a separate project for every simple little program or code snippet you want to create. You can just create one project -- and call it something like "Non-Project files". Eclipse has to have a project because you need some place to specify what version of the JRE to use, as well as other libraries, and you need to map where the files are going to be in the file system. That's really all the project is.

Then you might try creating a scrapbook page (File / New / Other, then navigate into the Java Run/Debug section and select Scrapbook page. In a scrapbook page, you can just type Java text and then execute it.

For example, I could enter

System.out.println("Hello, World");

select that line, and then right-click and select execute (or just choose Command-U), and you can execute the code right there -- no need for a class file, main method, etc, you can just write and execute as much or as little Java code as you need.
 

jcgnu

macrumors regular
Original poster
Dec 30, 2006
113
0
That's not an unusual feature. On the Mac TextMate has it (or you can run an Ant target). I'll bet BBEdit has it too. On Windows a lot of editors offer a quick compile and run: Textpad, JEdit (can use on Mac too), UltraEdit, etc.

I usually just use whatever text editor is handy, and compile/run from a bash shell if it's just a quick and dirty single Java class with no package or dependencies. But I also use Eclipse's "Scrapbook Page" for running snippets of code to test/try things.

But if I already have a project, I like to create a class with some code and create a JUnit test to execute it. That way, if it's something I keep and use, I already have a unit test for it.


Thanks for the help.

Actually TextMate is very close to what I was looking for. Two problems, though:

1) Is there any way to just compile? I mean, instead of compiling AND running, sometimes I just want to compile. Is that possible?? If not, it'll still be OK.

2) It's not free, but I'll think about paying for it, because it IS a lot like what I was looking for.



Thank you all for helping me out!
 

RaceTripper

macrumors 68030
May 29, 2007
2,867
178
Thanks for the help.

Actually TextMate is very close to what I was looking for. Two problems, though:

1) Is there any way to just compile? I mean, instead of compiling AND running, sometimes I just want to compile. Is that possible?? If not, it'll still be OK.
I haven't tried this myself, but it should work. Add a command to the Java bundle. Copy and paste the compile part of the Compile&Run command.
 

jeremy.king

macrumors 603
Jul 23, 2002
5,479
1
Holly Springs, NC
You don't have to create a separate project for every simple little program or code snippet you want to create. You can just create one project -- and call it something like "Non-Project files". Eclipse has to have a project because you need some place to specify what version of the JRE to use, as well as other libraries, and you need to map where the files are going to be in the file system. That's really all the project is.

Then you might try creating a scrapbook page (File / New / Other, then navigate into the Java Run/Debug section and select Scrapbook page. In a scrapbook page, you can just type Java text and then execute it.

For example, I could enter

System.out.println("Hello, World");

select that line, and then right-click and select execute (or just choose Command-U), and you can execute the code right there -- no need for a class file, main method, etc, you can just write and execute as much or as little Java code as you need.


I completely agree. Wanting to use a text editor with some CL integration hackery seems so 1999...

I create a project in all my IDEs called Sandbox - inside that project you will find all my little single class programs that I write and run...

If you find an IDE overwhelming, give Netbeans BlueJ a try.

Edit: JCreator seems a whole lot like Eclipse to me...
 

jcgnu

macrumors regular
Original poster
Dec 30, 2006
113
0
Well, I don't have a problem with complex IDE's such as Netbeans or Eclipse... I use Netbeans A LOT... Never used Eclipse, but I love Netbeans!! Except for one little detail:

Sometimes I just want to write a program (probably not small nor simple) which I don't want to be part of a project. For example, I do a lot of programming in JSP. Everytime I create a servlet, I don't want it to be in a project and having to take it out of there everytime I make a new version.

The problem is, Netbeans doesn't allow you to do that. Either you create a Netbeans project, or you just don't use it! (or just compile it outside of it).

That sucks... That's what I like about JCreator in Windows. It allows me to create, edit, compile and run Java files without having to add them to a project.

Having both options is great, so I decide when I use each.


Edit: JCreator seems a whole lot like Eclipse to me...

JCreator is a lot different than Eclipse, especially because of what I stated before...



Thanks for your comments.
 

stathis.z

macrumors newbie
Jul 27, 2010
1
0
From what I understood from your posts, all you need is a lightweight program to just write, compile and/or test code.

There is a freeware application called BlueJ, developed by Kent University as a java learning tool, that i think it actually fits those needs perfectly. It also has good step by step debugging capabilities, javadoc generation function and it can compile your code without you ever having to run it. Interface is quite simple and the program is really easy and fast to use.

Here's the link, i think you should try it out.
http://www.bluej.org/download/download.html
 

mrbash

macrumors 6502
Aug 10, 2008
251
1
I know exactly what you mean. Sometimes I just want to write a single file to test something out instead of a new project. Unfortunately there isn't much available.

I did a quick search and there is DrJava. It seems pretty straightforward and lets you just write a single file, and compile from inside of the editor.
 

WizCraker

macrumors newbie
Jul 28, 2010
2
0
I find that xCode is difficult to use compared to other IDEs, but once you figure it out it kind of grows on you.

When I was learning Java I used xCode after getting comfortable with its way of doing things, but I also used TextMate religiously. You can compile and run the single or project Java from within TextMate.
 

RaceTripper

macrumors 68030
May 29, 2007
2,867
178
I know exactly what you mean. Sometimes I just want to write a single file to test something out instead of a new project. Unfortunately there isn't much available.
I use TextMate for that. I can edit, compile and run a single Java source file from the editor very easily.
 

rdyornot

macrumors newbie
Sep 15, 2007
28
3
FYI: I use Netbeans, and you can make executable files without making a new project each time. Just make one project, then within that project you can make as many executables as you like. Just compile and run whatever you need individually and it works just fine.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.