Friday, November 25, 2005

Eclipse : Writing java snippets in a scratchpad

For web server development, especially when the code is in a jar file, you need to write some code, stop the application inside the server, deploy the new one, start it all up etc. That takes time - and then you find that the code doesn't work so you try something else which takes more time and so on ...

It's much easier to write the snippet inside an Eclipse scrapbook first and test it.

"File / New / Other / Java / Java Run/Debug / Scrapbook Page

Then just write some code in the editor e.g.

System.out.println("Hello");

Then highlight the snippet, right click, "Display"

Bingo!

Enjoy!

5 comments:

Unknown said...

Great post, thanks.
You can also use Control + Shift + D to display the result.

Unknown said...

Great for quick testing, thanks!

If you find yourself calling something this way a lot, though, that's a clear sign you should be calling it from a unittest instead.

Chloe said...

Also consider http://ideone.com/. You don't have to clutter up an existing Eclipse project.

Chloe said...

Also consider ideone.com. You don't have to clutter up an existing Eclipse project.

Unknown said...

I just created a java scratchpad:
http://jpad.io
I think you might find it useful. It can't quite cover your use case yet but I am working on it.