IDEA: previous commands in console - java

I am using IntelliJ IDEA version 11. And debugging my application using console.
Is it possible to use previous commands like in Linux shell with up arrow?
Also it would be great if I can prepare a list of commands and then select them in a smart way.

I am afraid that this is not possible.
For accepting user input(e.g. System.in), one can use either the built in console or one can even add an external command line tool as described here in the documentation. In Windows, I was able to successfully add the standard DOS prompt command line program to IntelliJ and use that to issue any commands that would be accepted by the OS, but even in that case, you do not have command history or autocomplete as discussed here
In the Editor setting, I see a setting "Console commands history size", but setting this doesn't seem to have any effect.

I may be missing something, but what console are you talking about? Debug console is output only, and command line console (which is not bundled with IDEA anyway) does have the arrow feature you asked.

Related

How to clean the output of netbeans in a "console" application?

I am migrating code from C # to JAVA in Netbeans for class work and I have a little problem with this; in C# I use Console.Clear to clean command prompt and make it look readable and very interactive, but in Netbeans it doesn't have a function to clean its output, what it does have is the "Clean" with the shortcut "Control + L", I found that the "Robot" class could be used to "automate" it in a certain sense but I don't know why but the normal sequence like being canceled or crashed, nothing appears after applying a "System.out.println".
Then I would like to know if it can be done in another way (except run it by cmd using the command "java -jar path")
1 - First solution, sadly, on Windows, there is no clean way of doing so. You'll need to use a load of System.out.println(""); in order to do so.
2 - The second solution, on Unix systems, there is an ANSI Escape Sequence that accomplishes that, and it's \033[2J once printed this will clear the console.
3 - The third solution. Install a plugin for NetBeans to make the console support ANSI sequences which would allow you to use colors and the \033[2J method.
4 - Finally, there's a Java library for that purpose that detects the current console/terminal and allows you to interact with it like you would with any other ones. Its called jcurses

How can I change VSCode's default terminal

I am a big fan of VSCode for how customizeable it is, but one thing really bugs me. I write code in Java, and for whatever reason scanners don't work with VSCode's default terminal, the internal console. It isn't a big deal, and I can fix it by just going into launch.json and changing the "console" option from internal console to integrated terminal, but it is annoying to do because one, I have to do it every time, and two, I have to run my Java file and watch it crash before the launch.json file even shows up.
TLDR: Is there some way to change the default so that it ALWAYS launches .java files in the integrated terminal instead of the internal console? I have looked around the settings multiple times and haven't found anything promising.
To be clear, I am not trying to change my default shell. I don't want to go from the standard prompt to powershell or bash or anything like that. I want to change the way it launches my programs.

How to move Java runtime console to different terminal window?

I executed a Java program from the command line in terminal app A. I want to move the console to terminal app B without having to exit and re-execute the program.
I can think of a few potential ways to solve this, ranging from:
A) In Java implement a new InputStream and OutputStream that somehow can be wired to a new process started in terminal app B.
...to
B) Find a way to put the main Java process in terminal app A in the "background" so that original process can be reopened in a terminal app B.
Ideally, I want to be able to "log in to" and "log out of" my Java process from any terminal on my computer. Has anything like this already been accomplished, and which approach would be best to make it myself? I am open to solutions that involve Java code, shell scripts, or both.
My specs:
OSX: 10.12.4
Usually running zsh on iTerm
If I was using Linux, the perfect solution would be reptyr, a command line tool that allows you to easily switch terminal windows.
On Mac, the best solution I have found is screen. It can also be used to switch terminal windows but must be invoked before running java in order to work and seems a lot more complex.

What is the use of Interactive Console in Eclipse (Debug view)

Some threads asked how to use the "Interactive Console" in Eclipse since you cannot type anything in this console.
Some suggested you can "Display view" to execute code.
So what is the purpose of the "Interactive Console" then?
Eclipse doesn't have an "Interactive Console" in it's default installation. It just has a "Display" view that you can use to execute Java code in debug mode in the scope of the current breakpoint (to evaluate expressions or to change data)
If you have an "Interactive Console", it's most likely a view from a plugin. I've read that a Google plugin might provide it. Or maybe a plugin for a scripting language like JRuby or Groovy.
If you say you have an "Interactive Console" and cannot type into it, then I suspect you're not in the right mode for the view to be active (maybe you're not working with the scripting language that provides the view).
Im sorry but the accepted answer is not correct.
The console in Eclipse is interactive, when a running application reads from the Console Input Stream.
It is not meant to be a feature of Eclipse to generally aid in debugging, it is meant to allow console based Java applications to read input from the user when debugging (as in I can type into a console prompt).
EARLIER ANSWER (accepted but not correct) :
The interactive console allows you to execute some extra code, while debugging, when stopped at via a `breakpoint`.
This is a really beneficial feature when you are debugging and suddenly want to change the value of variable, execute a sysout or some utility function.
FOR Correct Answer look at the answer below by #mmey.

How do I pipe the Java console output to a file?

I found a bug in an application that completely freezes the JVM. The produced stacktrace would provide valuable information for the developers and I would like to retrieve it from the Java console. When the JVM crashes, the console is frozen and I cannot copy the contained text anymore.
Is there way to pipe the Java console directly to a file or some other means of accessing the console output of a Java application?
Update: I forgot to mention, without changing the code. I am a manual tester.
Update 2: This is under Windows XP and it's actually a web start application. Piping the output of javaws jnlp-url does not work (empty file).
Actually one can activate tracing in the Java Control Panel. This will pipe anything that ends up in the Java console in a tracing file.
The log files will end up in:
<user.home>/.java/deployment/log on Unix/Linux
<User Application Data Folder>\Sun\Java\Deployment\log on Windows
/~/Library/Caches/Java/log on OS X
(If you can modify the code) you can set the System.out field to a different value:
System.setOut(new PrintStream(new FileOutputStream(fileName)));
If you are running a script (invoking the program via java) from Unix you could do:
/path/to/script.sh >& path/to/output.log
In Mac 10.8.2 logs could be found at /Users/<userName>/Library/Application Support/Oracle/Java/Deployment/log/.
Before you have to enable logging from Java Control Panel. Option "Enable logging" is at tab "Advanced". Java Control Panel could be started from "System preferences".
A frozen console probably means a deadlock (it could also mean repeated throwing of an exception). You can get a stack dump using jstack. jps may make finding the process easier.
try this guide it works for me. it also guides you that how you can set "System.setOut(fileStream);", "System.setErr(fileStream);"

Categories