How to start the java console when launching an application from Eclipse? - java

When I start a java application, the Java Console is started. But when I start a java application from Eclipse, the Java Console does not start on its own. How can I make it start also when I run an application from Eclipse?

Take a look at this topic .. I think it is exactly what you want.
There is an answer of how to be able to use step-through debugging from Eclipse.

What for do you need java console? There is window console in Eclipse IDE where all System.out.println are redirected.

If you are wanting the program to start in it's own window. Try running it as an external tool. The program would be cmd.exe and the argument would be your java command line, e.g. "java -cp c:\myclasspath myProg" and so forth.

First check that no other console is pinned, icon looks like window with a needle in it. This means that no other console except the one that is pinned will show the output. If everything else fails try to reset the java perspective in Eclipse.

Related

How to install Processing-Java in Windows 10?

I know that you can install processing-java using the tools menu in processing 3 app but it only works in macOS. In windows there is no option to install processing-java from the tools menu.
Furthermore, I tried installing using the 'processing-java.exe' in the installed folder ;
but it will just open a cmd window and it will get closed as soon as it pops up.
Additionally, I tried typing the command processing-java in cmd prompt and it says it isn't a command. Finally, can some tell me how to install processing-java.
You don't have to install anything, and processing-java.exe doesn't actually display anything. You need to run it via the command line, and you need to give it arguments to work.
Open a command line to the directory that contains processing-java.exe and then type processing-java.exe and hit enter. You should see an output of the arguments you can feed the tool.
Also note that 99% of Processing users never have to touch this tool, so make sure you actually need it before you try using it.
Without installing processing-java from the tool menu in the Processing app, you can still execute it in the console from anywhere using its full path, e.g. C:\Users\yourname\Documents\processing-3.4\processing-java.exe.
A command to run a processing sketch can be C:\Users\yourname\Documents\processing-3.4\processing-java.exe --sketch="C:\Users\yourname\Documents\sketchFolder" --run.

Javaw.exe won't run .jar file while java.exe will

I have a java app that I wrote. I am able to execute it using Ant and with "java -jar" from the command line. I want to be able to launch the file using "javaw.exe" (my app uses Swing). For some reason it doesn't seem to do anything (javaw starts for a second and then quits with no error that I can see). I tried running the same file on my Win XP computer using javaw and it executes fine. The other computer I am using it on is a Win 7 laptop.
Building on purtip31's comment ...
I expect that the problem is that some exception or error is occuring when you launch using javaw, but you can't see any diagnostics because they are going nowhere.
In the short term, redirect standard output to a file and look at what is being written.
In the long term, replace your "System.out" and "System.err" diagnostics with proper logging via a logging framework such as log4j, java.util.logging, etc.

Windows Registery: How to add a Java app to startup list?

I added a value at:
HKLM\Software\Microsoft\Windows\CurrentVersion\Run
That looks like this:
Value Name: LDE
Value Data: "java -jar C:\LDE\lde.jar"
Really with the quotes (Because all the others where also with quotes). After adding this, I restarted my computer, but it didn't start automatically.
Will wrapping my jar in an exe help?
I'm running Windows 7.
Any help?
Thanks in advance.
Update:
When I remove the quotes, it works. But now there is appears also a terminal, which I don't need...
A couple of things to note here, concerning the two different issues in the problem:
Format of Windows Run keys
From the Microsoft Windows XP knowledge base:
Run keys cause programs to
automatically run each time that a
user logs on. The Windows XP registry
includes the following four Run keys:
HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run
HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunOnce
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\RunOnce
Each of these keys has a series of
values. The values allow multiple
entries to exist without overwriting
one another. The data value for a
value is a command line.
Note the emphasis on the last line. The moment quotes are used, the command is bound to fail execution in the same manner it fails as if executed from a command prompt.
Also, note that the above approach is for Windows XP and does hold good for Windows 7. More details can be found in this Microsoft Technet article on the options available in Windows 7.
The javaw vs java application launcher
Once the java process can be initialized at Windows startup, one will get a console window that continues to stay around until the process is terminated. This occurs if the java executable is utilized to initialize the application.
From the technotes of the java application launcher:
The javaw command is identical to
java, except that with javaw there is
no associated console window. Use
javaw when you don't want a command
prompt window to appear. The javaw
launcher will, however, display a
dialog box with error information if a
launch fails for some reason.
Therefore, if you wish to avoid opening a console window for the Java process, you ought to use the javaw executable.
This is very simple. You will find the startup folder in the C:/Documents and Settings/AllUsers/YourUserName/StartUp. It will be on similar kind of path just check it. Then just paste your jar file in that folder and it will work nice. Remember that you put the jar file in the startup folder of your user name folder. You may find that this folders might be hidden so just check it out. If you find this answer useful vote it. Enjoy.....

How do you pull up the java console in OpenSUSE or Ubuntu?

I'm working on a java applet, and I was wondering where the heck System.out was going in Ubuntu/OpenSUSE. In windows, I just pull up jconsole, but I've not found this in Ubuntu/OpenSUSE.
Thanks.
Run the command jcontrol. On the Advanced tab expand Java console and select Show console. Restart Firefox and the console should open the next time you open a Java applet in the browser.
Also, you can run firefox from the terminal to see jconsole output. Jconsole output goes to firefox's standard out.

Is there a way to the hide win32 launch console from a Java program (if possible without JNI)

You launch a java program from a console (maybe using a .bat script).
I don't want the console to remain visible, I want to hide it.
Is there a simple way to do this ? Without JNI ?
Use javaw.
http://java.sun.com/javase/6/docs/tooldocs/windows/java.html
The javaw command is identical to java, except that with javaw there is no associated console window. Use javaw when you don't want a command prompt window to appear. The javaw launcher will, however, display a dialog box with error information if a launch fails for some reason.
You can start a java application with start javaw. It will hide the black console window.
This .bat trick works for general programs so I think it should also work for launching java program:
Call start program instead of just program in your .bat script
You can hide the console by using javaw.exe (java without) instead of using java.exe.
One of the most useful associations to set up is to make *.jar files executable with java.exe. Then you can just type the name of the jar on the command line to start it executing.
If you use javaw.exe rather than java.exe you won’t see the console output. Watch out, Java installers often associate *.jar files with javaw.exe instead of java.exe, overriding your setting.
download jsmooth and create your own custom exe in a minute or two. Then just use that exe to launch your java app. You can even get slick and bundle a JRE with your app.
http://jsmooth.sourceforge.net
In case fo running from but file your script should look like
start javaw start javaw -jar ***.jar
Note, that you may need running javaw.exe by providing full path to the file, that may need adding quotes " in case there are spaces in the path. The quotes will trigger recognition of them as "title"-argument for the "start" command.
So, use following correct format:
start "MyTitle" "c:\Program Files (x86)\Java\jdk1.8.0_202\bin\javaw.exe" -jar myApp.jar
where title can be empty if needed

Categories