views:

815

answers:

5

I am quite new to java, and I would like to learn java just like python, with the interactive shell IPython.

I try a few a them, like beanshell, jython, jythonconsole, JyConsole... Almost all of them don't have the function of tab completion like ipython. Is there anything similar to that? Thank you.

A: 

what beanshell have you used ? the old one ? Look at this they claim to provide completion

LB
I am now using eclipse instead of netbean, since I am also coding other languages like python and c++. I just use beanshell from http://www.beanshell.org/
i-freaker
+4  A: 

You probably won't get much use out of using java interactively, as that language is strongly oriented toward compiling. The best route will probably just get a nice IDE, like eclipse, and get started with breakpoints and the debugger.

TokenMacGuy
I actually use Beanshell quite often, lately beanshell 2 (http://code.google.com/p/beanshell2/). However, I have not found a variety with code completion.
Matthew Flaschen
I didn't mean to say that its impossible, or even non-useful to use Java interactively. I have used and enjoy some C++ interpreters for various tasks. But because these languages are not designed with such use in mind, you don't get the same level of utility as you would with more interactive oriented languages like python.
TokenMacGuy
If you tried beanshell, it extended java to be more scripting language like, in which you don't have to declare the variable type. There are much more advantages like closure, but I just started using that.
i-freaker
A: 

I think I find a good enough alternative: JPype. JPype allows python programs having full access to java class libraries. With JPype and IPython, I can use all java functions while having very nice tab completion for the java classes.(After the class is imported though)

i-freaker
+1  A: 

If you want an interactive option for use with java try using Dr Java or JGrasp, they both provide the same interactive option as does IDLE for python, plus being a fully based IDE with a debugger I prefer JGrasp to Dr Java. They also have a Dr Python so if you get used to Dr Java you can also use it with Python.

Also Dr Java has a feature in which you can select from beginner, intermediate, advanced and full Java in order to limit what you can do with the language as you learn it. I never use that feature as I dont see the point in restricting parts of the langaue but I guess some teachers utilize it while teaching there student.

Shane Miller
A: 

Although I agree with TokenMacGuy saying:

The best route will probably just get a nice IDE, like eclipse
As Im also coming from environment where tool like interactive shell was essential. So I can also suggest you simply using tool like ipython directly from jython/JPype.

That can be achieved or using JPype as suggested by i-freaker of through jython:

  1. Getting jython (check its running jython -c 'import os; print "Python meets %s" % os.name')
  2. Getting readrline (In case Mac sudo port install readline)
  3. Fallowing the steps from this blog or jython documentation to make java-readline work
  4. So you have jython with readline by now(Ctrl+R in jython results in reverse-i-search like you know it from the shell). In order to get tab-completion like you know it form ipython fallow the steps from this blog
  5. That should be it! In case you need patch for ipython 0.10 you can get it from here.
ssspiochld