tags:

views:

719

answers:

15

Can anyone recommend a light Java IDE that doesn't require you to make new projects each time you want to compile and run a program? I just want to be able to open java files and compile and run them. I have already tried Eclipse and NetBeans but both require you to make a new project each time you want to compile and run a program. Making a new project is fine for large scale projects but for small school assignments this just makes the process more tedious.

Thanks

+19  A: 

In Eclipse, you can just paste code into the package explorer without a given project, and a new project is created containing a file with that code, inside a main method. If the text you paste is a full class, it will name the file according to the class name. You could also set up a single project for your stuff and paste the code or the files you want to run into that project.

Fabian Steeg
I didn't know that. +1 for a very useful tip!
finnw
A: 

You need a well defined classpath before you can just compile you classes, and that's exactly what the project setup is for.

Just create a project once and forget about it - use it for all your stuff.

Yoni
+5  A: 

I've used Notepad++ to do this for simple Java projects and it worked quite well. Here is a guide on how to do this.

You may also want to check out jEdit, I believe it offers similar functionality, and may be more feature-rich for Java than Notepad++ is.

Kaleb Brasee
I tried using jEdit and downloaded a JavaSideKick plugin for code completion but it didn't work.
Andrew
+1 for jEdit. Neat, simple, robust. Esp perfect for small school projects
Mihir Mathuria
A: 

you can use cedit. which is not exactly a IDE but you can have compiler and JVM tools attatched to it and you can do whatever you have mentioned. i mean creating a small java file compile and run.

you can that here http://mac.softpedia.com/get/Word-Processing/CEdit.shtml

GK
+21  A: 

I've been doing java school assignments using Eclipse. I had one project called "Homework", and created a new package for each assignment. That worked fine for me.

Update: in addition to the practice suggested above, it seems eclipse has a subproject (still in incubation, though) called ide4edu that is specifically for educational purposes.

The Eclipse IDE for Education is a version of Eclipse streamlined specifically for use by university and college students.

Bozho
I use Eclipse for my major projects, but I do have a "sandbox" project where I can experiment with miscellaneous code snippets and such, which is basically the same thing you've done. Works nicely.
Jeff
Jason
Similar. I have a sandbox project, but I don't leave code in it for long. If it's good enough to reuse then I move it to another project/package.
finnw
+2  A: 

How about using a editor like Vim, or Emacs and then install some plugins so that you can have basic IDE features like code completion, etc? You will need to do bit of monkeying to get the right kind of combination and comfort. But, it could well be your answer for a lightweight IDE, one that does not require you to create a project.

Amit
+3  A: 

It might sound geeky or "not for novices" but in order to compile and run a single file the best option(in my opinion) is a console environment.And of course you can view them from notepad++ or any editor with similar fetures(especially highlighting).

DarkFire21
That's what I am currently doing for small assignments but Notepad++ doesn't have the features of a full IDE, like code completion. I use cmd to compile. I use NetBeans for larger projects.
Andrew
You're on the right track, but cmd is pretty poor as command-line interfaces go. Try one of the various Unix shell ports, or 4NT if you prefer the DOS-style syntax.
Porculus
I think this is a good approach; as well as being lightweight and fast, it will force you to understand how javac works, especially the classpath (which can be a nightmare).
Adrian Mouat
@PorculusYou are right...I changed it to "console environment"
DarkFire21
for me it's perfectly adapted to novices. Learn to use javac before use an IDE.
chburd
+1  A: 

What's wrong with creating project? Just create it ones and then use it for all your assignments. That will let you use any good IDE (NetBeans, Eclipse, Intellij Idea, ...) which, from other side, greately simplifies writing java code.

Xonix
+1  A: 

I recommend bash. I write a lot of test programs for work (and for the likes of answering stackoverflow questions). javac MyMain.java && java MyMain and you are done.

I have done one project and many unrelated packages, but that sucks. It also cannot cope with more complicated build cases (when dealing with, for instance, serialisation or class loaders).

Tom Hawtin - tackline
I used to do that, but nowadays I use guava and JodaTime in almost all projects, even tiny ones that I spend 4 hours or less coding, and I miss the automatic completion/import of library class names that you get in Eclipse/emacs/Netbeans.
finnw
I learnt to type and to know my libraries. That sounds sarcastic, but it is true.
Tom Hawtin - tackline
A: 

Why don't you create one project and fill it with all the programs you ever write. There is nothing forcing you to create a new project each time. The only reason to have multiple projects is to make managing the programs easier. So if projects don't make your life easier don't create multiple projects.

BTW: I suggest IntelliJ as I believe it is better, but in this case I suggest the problem is how you work and changing IDE won't make much difference.

Peter Lawrey
+2  A: 

My school uses DrJava for the first intro to programming class. Its a lightweight IDE and allows you to create folders on the fly for your java classes.

However, my classes now require Eclipse or Netbeans, and it did take some getting used to them. In some places, Eclipse is overkill for a second-year CS student, but I do like its features & am having fun exploring the extensability with other languages.

Jason
+2  A: 

NetBeans can have an arbitrary number of classes with main() methods. Create a project named school using NetBeans and create a new package for each group of related assignments. Customize the default configuration menu to make F6 run your current main(). At the same time, develop your skill with bash and a favorite command line editor.

alt text

trashgod
+1 for the concept
stacker
+1  A: 

Personally I enjoy using Emacs for editing my code than then Ant to build / compile my Java code.

Bare in mind that using a lightweight editor will generally mean loosing out on some very useful features, for example:

  • Auto completion. So for example in Eclipse if you start typing System.out. you can a list of options to complete the statement along with which parameters the function will require

    • Mistake highlighting : nice "red swiggly lines" highlighting simple mistakes

    • Build path management : adding external archives is trivial in eclipse less so from the command line for those with little experience

Amongst many others.

Personally I'd way up whether the "faff" of setting up a new project for a simple Java application is worth loosing those really useful features. And that usually varies per task.

dangerstat
A: 

Some universities (like mine) use

BlueJ

for Java Teaching. It basically got everything you need for your homework assignments, and it got NO code completion, which I find perfect for Java beginners ^^.

Helper Method
Unless you want to train your students to hate Java, how is this an advantage?
finnw
When I start learning a new language, i prefer using the command-line and a simple editor, because this helps me to better learn the basic commands, API's etc. ... but maybe that's just me
Helper Method
@finnw: When doing the first few CS courses I found it useful to use a very minimal editor. This allows you to really understand loops and ifs and all that fun stuff. If you don't get your hands dirty when learning the basics debugging is HARD later.
sixtyfootersdude
A: 

This sounds redundant, but the posters are right. However, you know what you can run. If you don't have the resources and you need to run a webserver, putty, etc.. notepad ++ would work (light enough). If your desktop is nice and can handle it, use Eclipse (vast adoption). Create a java project and add packages to it (as Kaleb, Frank and other suggested).

Josh Molina