I've created a Java application and converted it to an .exe using Launch4j and it runs fine. But when it is closed, the "Java (TM) Platform SE Binary" task remains running in the Windows Task Manager. Each instance of the application I run creates a new task for this and they need to be manually end-tasked.
Any ideas why this would happen? I've only been coding in Java for about 3 weeks and this is my first application.
Hope it's ok to add links to the application + zipped source code. I can't add the source code directly as it is too long. Thanks for any advice or suggested solutions.
Application:
http://www.filedropper.com/folderencryptor
Source Code:
http://www.filedropper.com/folderencryptor_1
I forgot that my application opened another JFrame to display some options and I had not set any action to occur when the close button in the frame was pressed. By default, Java sets it to 'hide the frame' when closed(not helpful Java!!). So Java was still using the frame, and hence the Windows task was still running.
So all I had to do was add...
optFrame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE)
...inside the initialization code for the options JFrame. In short, don't forget to dispose of JFrames when you're done with them.
Related
I made a java program, exported it from Ecplise as a runnable jar, and then used an app called "Launch4j" to wrap it with an icon into a .exe
This picture shows another app I have on the left. It has 2 instances open and you can see they overlap on the taskbar. My app is the little house, and the two java icons on the right are 2 instances of my app. How can I make my app overlap on the original icon like the other app?
Edit:
Additionally, in task manager, my app opens as "Java(TM) Platform SE Binary" instead of the .exe file as you can see eclipse does.
Thanks!
I'm guessing that windows uses the AppId to determine what buttons to stack on the taskbar.
So you would need to tell windows the AppId, which I don't think is very easy with Launch4j.
Instead you might try Inno Setup, here's a good answer explaining the differences.
Inno Setup should include examples which tell you how to specify your AppId among other things.
I am building a statistical analysis application on Netbeans RCP for solving tests faster and with less effort https://github.com/PaulMaxAvalosAguilar/Statistikos-Klubas.
The thing is very simple:
1.-There's a module called TrabajosViewer which uses the nodes API to display workspaces where you can organize your samples with some meaningful name, first you create a workspace and then you add some data to it.
2.- You open editor top component which calculates some descriptive satistics stuff for all the sample you entered
3.- All stuff you need for a test is done! Samples are stored in an embedded H2 database(datos module) and results are calculated each time you click on a TrabajosNode.
However when I was testing the app I had to add the following sample:
https://1drv.ms/t/s!AkZmosJJMvdIu3c_IiVkD6JAVVgk (3344 elements); as the app had multithreading capabilities everything was fine, except that after building a release as OS independent zip the app froze from the swing Top Component which was very rare as that wasn't happening on inside Netbeans IDE. I think it has something to see with the build script since I built a Gradle version an everything worked fine https://github.com/PaulMaxAvalosAguilar/Statistikos-Klubas2
If you have an app - any Java app really, not just NetBeans RCP - and it freezes then what you want to do is obtain a thread dump. The thread dump will almost always give the clue as to why there's a freeze.
Java has 5 or 6 different ways to obtain a thread dump for a running application (just google it). Out of these methods, the one preferred is the so-called Ctrl-Break method because it is the one which gives most information. The downside of the method is that you need to have started your application from a console window. But if you can consistently replicate the freeze, then I don't think that's a problem for you. Here's what you would do if you are on Windows:
Start cmd.exe
From the command window, start your application, e.g. bin\sillyapp64.exe.
Wait for the freeze to happen on your application
Now press Ctrl-Break in the command window. This will give you a thread dump printed into your command window.
Upload the thread dump as part of your question. (or host it somewhere if it is too big)
Instructions for Linux/MacOSX are similar albeit in step 4 you would instead send your process a QUIT signal using the kill command.
In installer created with install4j when you move mouse over tooltip (for example radio-button tooltip), the installer freezes (hangs) for some time.
After long investigation I found (what is for me quite strange) that it is associated with attached java version. When in mediaSet I have java 6 everything works fine, as soon as I attach java 7 (windows-amd64-1.7.0_51) the installer hangs for the first time when I move mouse over any tooltip.
Any idea how to solve this?
Your thread dump shows that the AWT stalls in
sun.awt.Win32GraphicsDevice.isPixFmtSupported(int, int)
This seems to happen for some graphics cards. This is the bug in the JRE:
http://bugs.java.com/bugdatabase/view_bug.do?bug_id=6477756
It's targeted to be resolved in Java 9.
The workaround is to set the system property
-Dsun.awt.nopixfmt=true
for the installer.
My application is a GUI frontend for a database, and is built using Java's Swing library. The application is compiled using Java 5 (1.5).
When the application is ran using Java 7 I am able to write in textfields, comboboxes, etc. using the keyboard, until the data is loaded from the database then the cursor continues to blink but what I type is not typed on the screen. However, if I click on another windows e.g. my browser and then come back to my application, or minimize and maximize my application, the keyboard input works and behaves as normal.
When I run with Java 1.5 or 1.6, however this issue does not appear.Any insight on what might have changed in Java 1.7, and possibly a workaround?
PS: So far I made a workaround as follows:
frame.setFocusableWindowState(false);
frame.setFocusableWindowState(true);
However, I have this inside a timer, as I don't know where exactly the issue occurs. This is not really a proper solution...
Thanks
I am currently working on a research project for a University in which I am doing GUI interactions with my database and launching an external program based on the data. I'm using runtime commands (once the OS is detected) to launch that external program with the selected data.
My question is how can I embed an external program's GUI inside a Java frame, if that is even remotely possible?
Given the clarifying comments on the question, the short answer is "no, you can't do that".
Java cannot display a native program's GUI within a JFrame, even if the target program was actually architected to allow it's GUI to be presented within another program's frame.
Are you using a console application? You have to intercept its stdout to do it correctly. So you can show the text that the 3rd party application is outputting in an UI control that you can put into JFrame.
It depends from the application you want to embed to the JFrame, but you can try to use jawt:
https://docs.oracle.com/javase/9/docs/specs/AWT_Native_Interface.html
You will be able to get the native OS specific window handle and can draw on top of it, or can you use it as a container. Note that only HW components are supported, so you will need to add Panel/Canvas to the JFrame and then use that for your native app.
This is similar to this question:
Native JNI/JAWT Swing application runs successfully on Java 6, but fails on Java 7 (64-bit Windows 7 OS)
Use java.lang.Process or java.lang.Runtime.exec.
http://www.java-tips.org/java-se-tips/java.util/from-runtime.exec-to-processbuilder.html