I want to clear the console output of the NetBeans console. We can clear it manually by using Ctrl+L.
Is it possible to do this programmatically, in Java?
Thank you very much
I think that it's not so simple.
The Netbeans console is not really a full system console.
I'd see a proper option - like getting the console reference using the Netbeans RPC binding, but your application would need to run as a Netbeans plugin or bundle. (so - don't do that, keep it simple)
For a shortcut (workaround) - you may try to use java.awt.Robot class to send a keyRelease event (Ctrl+L) while being focused in the console (effectively sending the Ctrl+L event to the focused component)
This is a poor solution because it doesn't actually clear anything, but it does push it out of the way to hopefully make it more readable.
System.out.print("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
add or subtract "\n" to lengthen or shorten it depending on the size of the console window.
Related
I am creating a complex game, because of this I use System.out.println(); a lot to test to see if something works or to see if something went wrong. To see these messages I have been going to the CMD or terminal and running it from there but I was wondering if there was an easier way. I thought of a couple ways and came up with running with a batch, but I have no idea how to make one, and another way was to put a button in game that opens the console that the game is running in. I don't even know if the second one is possible but I was wondering if there was a way! Thanks in advanced!
This is what logging frameworks are for.
Use sfl4j - http://www.slf4j.org/ - in your code to generate the log events, and choose a suitable backend for your purpose. I would suggest using slf4j-simple which is easy to get started with and which easily can be sent to a file you can view in your favorite file viewer.
http://www.slf4j.org/api/org/slf4j/impl/SimpleLogger.html
I'm looking to write a relatively simple key macro for my own edification and also for my own use.
I intend for it to be able to run in the background when I run other programs, and at the press of a button will enter certain text into the active window. To be more specific, I want to go in a video game and use it to automatically send messages instead of having to type them.
I Googled around a bit, but apparently I'm not using the right keywords because I'm not really sure where to start. The closest I came was finding the Keystroke class, but that appears to be used for receiving keystrokes, not sending them.
I would appreciate and info regarding, or directing me to a resource for, these issues (how to send keystrokes to windows and anything about targeting which window etc).
To send key strokes you can use java.awt.Robot
To Choose which window to activate you can look around for ws script (windows script) or old VB6 code and use it to make VB script (simple text file of extn .vbs)
Or you can junk all that and use http://www.autohotkey.com/ which has window activation, sending keys, doing things on press of certain keys (like Windows Key + B) or macros.
To get a window to activate I had made an exe long back, but no longer use it, can get it from http://sourceforge.net/projects/win-utils/files/Window-Position/rel%2001/ (but only get this if the others do not work as need to seperately get COMCTL32.ocx and install that
If you do not want to use autohotkey you can use Jini to call platform specific functions, with a wrapper to call correst OSes functions. Never done it my self, when i had to use it i would make a process to call a exe that made the window come the front.
I can't figure this one out.
I have Java code that captures Webcam, it works awesome for what I need.
Issue comes along when I am trying to make an Applet out of it. I made applet, but it simply doesn't work. It doesn't create any visible errors, doesn't complain about libraries, basically nothing I can grub on to. The only thing I can see in Console log (Mac OS 10.5) is following message:
PluginProcess[10143] Process manager already initialized -- can't fully enable headless mode.
I don't have any ideas on how to fix it. Please Advise.
Thank you.
P.S: I just want to make Java Applet out of existing code so I can dump it into machine (any) and it can stream video from webcam.
https://bugzilla.mozilla.org/show_bug.cgi?id=574904#c23 says "this message is a
red herring: You always see it (using Apple/Sun's Java Plugin2) whenever any
Java applet is displayed."
that might be some kind of a silly question for you guys, but anyways: Is it possible to start the Java-console (as it is shown in Eclipse) parallel to the actual SWT-GUI?
The console contains an awful lot of debugging-information and I want my testers to be able to see what's currently going on. Obviously, they're not gonna use Eclipse...
Start your program using java instead of javaw.
Another way is that you abstract your logging mechanism so that it uses console if one is attached to the process (when started with java or within Eclipse) or puts the messages in a separate window the user can open if they want.
Run the application with the parameters:
-console -consoleLog
I close my application by pressing a "Close" button. But in the Eclipse I see a red square indicating that something is still running. When I press this red square, I kill my application completely.
Is it possible to find out what is still running (which method, which loop) using Eclipse?
P.S. I am a newbie. So, it would be nice to have a simple solution. I also might not understand your answer if you use "technical" words which I do not know.
ADDED:
I cannot use System.exit since it will kill not only my software but also an "external" software which calls my software.
Have a look at jps and jstack commands they will give you the process id for your application and then you can view the threads and their states using jstack.
Its very useful for this kind of issue.
Sorry just realised you wanted something in eclipse to do this. well I'll leave this answer as it should work but not inside eclipse.
Debug View shows just that. To see the concrete methods for each thread you need to stop the application. Most probably you just need to set default close operation for the main JFrame.