Java's interactive shell like ipython [closed] - java

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 4 months ago.
Improve this question
I am quite new to Java and would like to learn Java using an interactive shell, like I did with Python using IPython.
I have tried a few interactive shells, such as beanshell, jython, jythonconsole, and JyConsole. Most of them don't have tab completion like IPython does. Is there anything similar to IPython for java?

groovysh:
http://groovy.codehaus.org/Groovy+Shell
Rich cross-platform edit-line editing, history and completion thanks to JLine.
ANSI colors (prompt, exception traces, etc).
Simple, yet robust, command system with online help, user alias support and more.
User profile support

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 their students.

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.

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

Gayan Weerakutti already mentioned in a comment what I think should be the correct answer, too:
JShell is part of the JDK since version 9.
Try jshell on your terminal.
Check out docs from Oracle about it.

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)

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:
Getting jython (check its running jython -c 'import os; print "Python meets %s" % os.name')
Getting readrline (In case Mac sudo port install readline)
Fallowing the steps from this blog or jython documentation to make java-readline work
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
That should be it! In case you need patch for ipython 0.10 you can get it from here.

Give a look at https://github.com/Bachmann1234/java9_kernel you can install a Java kernel for IPython and use it (also via the notebook).

IntelliJ IDEA has a groovy console with tab completion.
open it: Tools -> Groovy Console...

Related

VS Code and Java

I am totally new to VS Code and as I want to start learning Java for Android development. I saw that the Java language was supported by the VS Code IDE so that was good news. Ok but how would one exactly approach developing anything in Java via VS Code? I mean what is the build process for compiling anything I write in Java? Would I need to write some special tasks.json or?
What I would like to start with is a simple "console" like Java application build with VS Code. I would appreciate any information regarding this topic, thank you.
You will need to install the java language support by pressing F1 and entering ext install java.
You will need to install maeven or gradle (or ant?) for your build process.

How can I obtain an interactive shell (like Ruby's irb) for Java?

I spent the last year doing Ruby development, and during that time I discovered irb, which makes running little "code experiments" easy and fun. I've recently switched teams and am now doing Java development, and I've found that I really miss my irb window. I would like to do the same thing for Java, but I don't know how.
I'm using Eclipse (groan), but Eclipse's bells and whistles are not the same thing.
BeanShell is probably what you're looking for.
https://github.com/beanshell/beanshell
There are a few choices: BeanShell has been around for a long time, and is a great Java REPL.
Another alternative is groovy's groovysh or groovyConsole. While groovy isn't Java in the strict sense, it's great for interactively playing around with Java classes.
Old question, I know, but jshell: The Java Shell (Read-Eval-Print Loop), is coming in Java 9 (Summer 2017, hopefully).
Would "Use an Eclipse Java Scrapbook page" be better ;-)
I haven't actually used irb, but if you just want to run code snippets inside of eclipse, then this is a simple way of doing it.
Tried JShell and beanshell.
Do suggest JShell over beanshell. Up key will roll back to history lines. Display much user friendly.
Thank you #Anders Sandvig
It can be found in jdk since java 9.

Java IDE with VIM integration for someone coming from C/C++

I'm an experienced C/C++ programmer getting into Java and looking for a good IDE with VIM integration or a VIM plug-in that let me use the same key mappings for things like editing, cscope and omnicompletion functionality. What I mean is that whatever native functionality is provided by the IDE can be mapped to the equivalent vim key bindings. It should run on both Windows or Linux. I don't care if I have to pay for both the IDE and the plug-in as long as they meet my needs.
The most recent question I saw dealing with this type of question here on SO is over a year old and I'm sure the 'state of the art' has changed since then.
I want to hear from people with actual hands on experiance with these IDEs and VIM plug-ins.
Why not just use VIM?
You know exactly what it can do and how it can be extended, and it appears to be what you want anyway.
You will not be satisfied by any emulation as it will fall short, and with your current mindset you will not like having to learn a new editor. It is, however, what I will recommend you to do. The things modern Java IDE's can do are miles above what VIM can do because they know your source intimately. You will benefit the most from an IDE if you use its default configuration, and I do not know any which wants to look like vi/vim.
When THAT is said, you might find http://ideavim.sourceforge.net/ interesting. IDEA is the only common place Java IDE left which makes money...
There's a VI plugin for IntelliJ. I've never used it, so can't comment on its userfriendliness, but IntelliJ itself is excellent.
Recently when I've been coding Java at work I've been using vrapper It has some minor usability bugs and some missing features (such as cit) but it really seems to work well in just providing basic vi editing functionality.
Ok, it seems I misread the original question a bit by looking too much at the other answers. I don't really know how easily you can map Eclipse's native omnicompletion functionality to the corresponding vim mappings. However I think you can be very productive with the bindings provided by wrapper and by learning just a few of the most important coding assistance keys in Eclipse.
There might even be a Stackoverflow question about this but the most important shortcuts I've found are:
ctrl+space for "omnicompletion"
ctrl+1 for opening the menu of suggested quick fixes for an error or warning
shift+ctrl+t for opening a type
I've been using the viplugin for eclipse (http://www.viplugin.com/viplugin/)
It's quite good, fights a little bit with refactoring, but most of the main editing commands work. I still have to use vim for complex regex work, but I only have to do that about twice a year.
Unfortunately it's commercial (€15) and development seems to have slowed a lot. It seems to be currently more feature complete than vrapper, but I haven't tried that.
I'm also researching VIM / Eclipse integrations, and these seem most interesting:
Vrapper
Eclim
(according to this Hacker News discussion and this other SO question)
Looks like there is one for netbeans, (a stack overflow thread) Is it possible to use VI or VIM keymap in NetBeans?

Java licensing for commercial distribution [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
I'm thinking of using Java to write a program that I might try to sell one day. I'm new to Java so I have to ask, what types of tools/software/etc will I need (from development, to distribution, to user-friendly installation on users' machines) that have licenses that must be considered to make sure they allow sales and closed source code, etc.?
Should we assume the user already runs at least one Java app, and therefore has a fairly recent version of Java on their machine?
Also, do you have any recommendations for specific tools that are definitely suitable for this purpose?
It's very rare to see any development tools that restrict the way you can use software created using them. The only exception to that are libraries, and that is not a problem with standard Java libraries. Tools, IDE and so on - regardless of whether they're free or not - will not affect how you can distribute your code.
There are some weird exceptions, like BitKeeper source control software, the license of which prohibits anyone using it from trying to create software that could compete with BitKeeper - which is why I advise to stay as far away from the thing, and the company behind it, as possible. In the end, if you want to be absolutely legally clear, you'll have to hire a lawyer and have him go through licenses and EULAs for all software you're going to use in your development process, because of stuff like this.
Some specific data points: Java itself is okay (both compiler and libraries); both Ant and Maven are okay; and Eclipse and NetBeans are okay.
For development, you will likely need an IDE. The top picks are:
Eclipse (most features)
IntelliJ (non-free)
Netbeans (easiest to learn, imo)
A few others with much lower popularity
For a free installation program, I've had the best experiences with IzPack, but there are others available. Similarly, to convert to a .exe for easy launching, I recommend Launch4J.
I don't think that its safe to assume that users have Java installed. Many will, but the versions will vary fairly widely, and the few that don't will tend to cause problems. Obviously, this may vary depending upon your intended audience (and how much control you have over them).
For cross platform distribution you might want to look into launch4j: http://launch4j.sourceforge.net/
Also you might also want to obfuscate and optimize your code, for that you can use ProGuard: http://proguard.sourceforge.net/
For your development use any of the open source tools available such as eclipse or netbeans, or even emacs with jdee.
You should not assume users have Java, package a version of java with your application.
For installation you might want to search for some open source solutions, the only one I know of is install4j and it is commercial. http://www.ej-technologies.com/products/install4j/features.html
This is a question that is really hard to answer because the requirement and the preferences of the users are different from each other.
But I will tell you one entry point. Use ECLIPSE as your IDE to develop your Java code. It is an opensource one so you don't need any licence for that. When you are working on your project you will need variety of other tools to do various stuff. Fortunately most of the essential functions are implemented as plugins for eclipse. You can seperately add them to eclipse.
With time, you'll get the experience and you will have enough knowledge to swich to the necessary tools etc

Best free Java .class viewer? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 9 years ago.
Improve this question
I've used DJ Java Decompiler, which has a handy GUI, but it seems as if the latest version is only a trial and forces you to purchase the software after some period of days (I recall using an earlier free version about a year ago at a previous job).
I'm aware of Jad and Jadclipse, but what I loved about DJ Java Decompiler was that it integrated with Windows Explorer - so I could simply open up a JAR in something like WinRAR, navigate thru the packages, and double-click on a .class file to view it's decompiled source.
Can anyone suggest other good, free, .class viewers? The criteria I have in mind for these would be:
GUI-based
Integrates to Windows Explorer (so I don't have to run some command-line options like with JAD)
optional - can also show raw JVM bytecode commands
In other words - I'd like to find the closest thing to .NET Reflector for Java as possible.
JAD is one of the best Java Decompiler today. This is one brilliant piece of software. Nevertheless, the last JDK supported by JAD 1.5.8 (Apr 14, 2001) is JDK 1.3.
DJ Java Decompiler, JadClipse, Cavaj and JarInspector are powered by Jad.
The last version of Decafe Pro has been released on 2002-01-03.
These viewers can not display Java 5 sources.
So, I use JD-GUI : logic, I'm the author :)
Procyon is a new open source decompiler that already beats JD-GUI in most cases. It's written in Java and comes in a self-contained jar. It is actively developed by StackOverflow's own Mike Strobel.
Eclipse will allow you to view the bytecode for classes, if the source is unavailable (search for 'disassembled bytecodes').
It seems there is also a third-party plugin that uses asm here.
There was another thread on StackOverflow which linked to http://java.decompiler.free.fr/
Try JDGUI simple, lightweight and fast
I use cavaj
I've used Decafe Pro (can't find the official site anymore) in the past, but the free version won't let you cut-n-paste.
Both of them are front ends to JAD, so they have the same features and limitations with respect to decompilation capabilities.
JarInspector
Jar Inspector is an easy to use yet powerful jar file editor for Mac OS X. It allows you to effortlessly view, edit and decompile the contents of jar files.
Many of these decompilers are based on Jad:
http://www.kpdus.com/jad.html
I like the JadClipse Eclipse plugin:
http://sourceforge.net/projects/jadclipse
I just published a stand-alone Java Decompiler GUI (based on Jad) which you can get from Util Java Decompiler (JAD based) v1.0
This is a Windows based .NET 4.0 application, which supports the drag n'drop of *.jar files.
It doesn't integrate with Window Explorer, but since this is based on a simple C# script, and the code is Open Source, maybe you could add that feature :)
Another idea would be to also add support for the other free java decompilers.
i use cavaj, simple to install and gives your very good overview of the class, eclipse style.
There is a free Java Class Viewer, we can check the Java .class file binary data byte by byte interactively. When clicking each tree node of the class file structure on the left, the corresponding byte data would be highlighted on the right.
Here is an article describes the source code of the Java Class Viewer in detail.

Categories