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
Related
I have this chess engine i wrote in java. Thing is, I need to make a exe application that can take commands following a certain protocol (UCI). Ive had many problems trying to get this to work, but ill keep this brief and share the most important ones.
Other engines pop up cmd when you click on them, mine is just a basic java CLI (Dont know if this is a problem).
My anti virus keeps stopping me from opening the exe. Launch4j gives me a warning telling me I should sign it to prevent this sort of thing, but I dont know what that means.
So heres the deal, I know this post is word vomit, but Im truly at a loss right now. Id like general order advice on how I should approach the problem and maybe some advice on wether i should be using launch4j in the first place.
UPDATE: The reason i wanted to make an exe in the first place is because thats the format that was suggested in the lichess documentation (I wanted to upload my bot to lichess). I wrote a bat file that executes the jar file and it worked fine. Thanks to everyone for the suggestions.
I'm recently working with Eclipse Che and have the task to import a Java Project that opens a GUI in it (like a simple Swing/SWT Calculator).
I am using the Java CentOS Stack, importing the .jar files, etc. is no problem but I get the "No X11 DISPLAY variable was set, but this program performed an operation which requires it." error.
Obviously, I found many threads about that Error, but I just wanted to ask if it is even possible to open a GUI in a web based IDE like Eclipse Che before wasting hours trying to fix that error when it's not even possible.
Maybe some of you already tried that and have a solution/tip or smth for me.
edit: found a video that answered my question. https://www.youtube.com/watch?v=AjgSp0dkxxU
Thanks anyway.
This will help you out - https://eclipse-che.readme.io/docs/che-and-swing
You need to use the right stack
You need to set the display variable. The way I did this was modify the run command to set it just before the other commands.
The command I used is:
export DISPLAY=:0.0
Also note that this worked for a while for me but randomly stop working a few days back so please tell if you manage to get it working.
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.
My java application has a button which should open a user selected Excel file when clicked. On this file the user has to select a diagram. Finally they should click a button which triggers a process (macro, java method?) which changes the size of the diagram to values read from an object of the java application etc.
When searching on the internet I found things like COM bridges for java like JACOB, but this seem to run on windows32 only; is there anything that works cross-plattform?
I would be very happy if somebody could help me to find a good approach, a fitting library or any other helpful hint, because I am a bit confused at the moment and don't know how to start at all ;)
Thank you very much and have a nice day!
edda
Check out http://j-interop.org/ . This can be used to call dcom applicaitons in a platform independent manner.
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