56

I've found LINQPad to be extremely useful when answering StackOverflow questions for C# or VB.NET. It allows me to write up some quick code, run it, and (if I want) see a nicely-formatted dump of the results. That way I can be sure that the code I post actually runs. Thus far I haven't seen anything that I can use to achieve the same result with Java. Is there anything like that out there?

I am not looking for something to query data sources; I just want a light-weight IDE. These are the features I'm particularly interested in:

  • The ability to write and run short snippets of code without establishing a whole project or file structure.
  • Reporting of compiler and runtime errors in the code when it is run.
  • The ability to add references to a particular editor instance.
  • Syntax highlighting and Autocomplete/Intellisense would be a plus.
StriplingWarrior
  • 151,543
  • 27
  • 246
  • 315

8 Answers8

50

JPad - A java scratchpad for running snippets

JPAD Java scratchpad IDE

Since I also couldn't find one I've decided to write one. Currently it can:

  1. Run java snippets (no class / imports / public blah... needed).
  2. Contains drivers for MS/MySQL/Postgres.
  3. Output results as HTML tables

It's very rough but I will add to it over time. Feedback is definitely welcome.

Ryan Hamilton
  • 2,601
  • 16
  • 17
  • 3
    Yes! It's about freaking time! Thank you so much! – StriplingWarrior Feb 04 '16 at 05:54
  • 1
    @Ryan Hamilton - wow this looks amazing. Upvote from me. Please add a PayPal Donate Button or something like that. Keeps up the motivation. Mention me here if the link is up. – Stephan Schinkel Feb 09 '16 at 09:19
  • @StephanSchinkel Added the donate link, though to be honest more what I would appreciate at this stage is feedback. A few guys from here have reported linux bugs that I'm going to fix. Two people wanted a command line version, so I've added that: https://www.youtube.com/watch?v=a9cI7WCw2Sc . Scripts can now be saved and ran command line by simply "jpad helloworld.jpad" – Ryan Hamilton Feb 16 '16 at 11:17
  • This is nice! Thank you.Re feedback, I would like to see this incorporate Android functionality. For example creating Activities, Fragments and Services on the fly. – Lee Hounshell Nov 07 '16 at 22:09
  • Love this! Coming from 10+ years of C# I'm looking for a way to learn Java differences. Additions for classes, enums, and other fundamentals would be very welcome since I used these all the time in LINQPad to test stuff out. Thank you! – jocull Jun 04 '18 at 19:25
  • 1
    Is there proper way to install Maven packages directly from JPAD? – hellboy Aug 31 '18 at 13:07
12

This may help : http://www.browxy.com:9000/codeRunner

EDIT: Url seems to have changed to http://www.browxy.com

Community
  • 1
  • 1
sinelaw
  • 16,205
  • 3
  • 49
  • 80
5

You can use the Groovy web console ; it's possible to speak java in groovy land.

Istao
  • 7,425
  • 6
  • 32
  • 39
  • I haven't looked into Groovy before. That's pretty sweet! I like the way I can use anything from an expression (`2+2`) to a multi-class program. I don't suppose there's any way to restrict the language to pure Java? (I don't want to accidentally post Groovy code in a Java post!) – StriplingWarrior Jan 31 '11 at 22:09
  • No, I don't think it's possible to restrict to pure java. But see the doc I'm not a groovy specialist. – Istao Feb 01 '11 at 09:00
2

Java Snippet Runner: Does something similar to Linqpad (jar file, not just for macs)

http://mac.softpedia.com/get/Development/Java/Java-Snippet-Runner.shtml

Code Runner (Commercial): for Mac's only, it'll run code snippets in Java, and lots of other languages too (e.g. Objective C)

http://krillapps.com/coderunner/

Brad Parks
  • 66,836
  • 64
  • 257
  • 336
  • That's a lot closer to what I've been looking for. It doesn't appear to support class or function declarations, but it's good for just writing a few lines of code. I could see myself starting with this, and then switching to the [browxy code runner](http://stackoverflow.com/a/4856968/120955) when I need to declare helper methods and such. – StriplingWarrior Jun 12 '12 at 15:25
2

http://ideone.com is an online service that has the features you want.

thSoft
  • 21,755
  • 5
  • 88
  • 103
1

I've been using JEdit for a long time, which is a very powerful cross-platform editor, NOT an IDE. It does have plugins to execute Java code right in the editor, and even uses BSH for macros.

dj_segfault
  • 11,957
  • 4
  • 29
  • 37
  • Thanks for the post. I actually looked into JEdit before posting this question, but it's not very obvious how to execute the java code from inside the editor. Can you provide more detail (i.e. which plugin to install)? – StriplingWarrior Jan 31 '11 at 21:59
  • JEdit macros are BSH, which among other languages can run straight Java. It's got added goodies to work with the editor, like accessing buffers and files and selected regions, but you can just write some java and save it as a macro. If you want something even faster, you can highlight some bsh-compatible java and choose Utilities/BeanShell/Evaluate Selection. If you want full Java, you can use the Maven or Ant plugins. Or use the Console/Commando plugins as outlined here http://www.stfrank.com/ExposureJavaJEdit.html – dj_segfault Feb 02 '11 at 06:20
0

I've been using IntelliJ IDEA and it works really well as a Groovy scratchpad. The Community Edition is free too.

You need to create a new project, but then can add Groovy scripts to it and run them on the fly. Not had any luck with the actual Scratch File functionality though.

Being a Jetbrains editor it's pretty slick too. (Unlike some of the other options)

Nothing beats LinqPad though.

John
  • 1
  • 1
0

I was looking for a "Java LinqPad" also, and i came across : this

Vlad
  • 83
  • 4
  • Ugh, the website has frames. You have to look for "Java Snippet Runner" on this site, because there's no way to link to that page directly. – StriplingWarrior Oct 18 '11 at 14:32