I made a Java application for a client that needs to be installed in the computer, the app connects to a SQL database in a server. When the app is in use runs normally until at a random moment it starts lagging despite no consult to the database is being done, something as simple as scrolling in the app gets slow and changing from frames gets really slow(maybe a minute or two when normally it takes half a second).
I read that the problem could be the Java version and that could be slowing the application, but after updating Java the app keeps lagging despite randomly and returning to normal randomly as well.
When the app is being used in Netbeans it runs with no problem and the code doesn't seem to be the problem because it works normally and it does what it's supposed to do.
Any idea of why the Java executable lags randomly when in Netbeans runs without problem?
Related
I have a bit of a weird situation. I finished coding my application last week and it was working perfectly fine. I launched it every now and then and it worked as expected. All of a sudden when I launched my application yesterday it stopped working. It produces no errors but sometime the screen goes black when I launch the app, some time it freezes and I can't do anything, sometimes it doesn't go pass the first screen.
I am really confused what happened as I am still running exactly the same code. Even when I try my previous backups it still does the same thing.
I have tried cleaning, rebuilding, running from different machines, running on different android device, clearing caches, data, uninstalling and reinstalling.
I have tried everything now but I can't figure out what the issue is. I am still running exactly the same code as it was 1 week ago when it was working all fine.
I have a simple java class that i want to run programmatically. This is basically a video player. It is also deployed along with my web application in tomcat. This should run upon a click on a particular link. From controller, here's how I run it
new Thread(() -> {
VideoPlayer.main(new String[]{});
}).start();
It is working fine. But every time I close the Video player, tomcat is also terminated. Any ideas on how to correct this?
Your GUI probably calls System.exit when you close it. That'll take-down Tomcat since they are both running in the same JVM. Find and remove the System.exit and you'll find things work-out better for you.
Also note that it doesn't make any sense for a web application to launch a video player. Think about it: once the web application is no longer running on your own personal development workstation, the video will be played on the server where there isn't anyone to watch it. The server probably won't even have a monitor attached to it. Most likely, you'll get a whole series of exceptions from the video player telling you it couldn't initialize itself because there isn't any graphics environment in which to start.
I have a legacy Java application that uses Java 1.3
It works fine on windows Xp but now I need to make it run on windows 7.
I have installed the 1.3 jdk however when it first loads, the app won't render properly. Bits of the screen just show grey background, selecting buttons won't load a new screen etc.
I do know watching the output from the app it just purely graphics not rendering properly.
However if I press "Ctrl-alt-delete" and then just press "cancel" the software runs perfectly.
If I have a second monitor plugged in, it runs perfectly.
Has anyone got any suggestions how to make app run perfectly first time.
Thanks
Firstly, update your java, no excuses not to.
You can try the hack of resizing your component to a different size and then back again. I find this is the best way to make sure that swing doesn't do this sort of mischief with black squares here and there.
These things happen from time to time with non native tools for desktop development as opposed to those specifically designed for the targeted platform.
We have happily been deploying our cross-platform SWT app with Web Start for years. On the mac we had to switch from using -XStartOnFirst to using the com.apple.concurrent.Dispatch class to get SWT to run in the first thread.
Java 7 update 55 breaks our app again, and again it seems to be Web Start related.
The app starts and displays all windows, but all interface interactions don't have an effect until you click some other widget. For example, if I click a tab to bring it to foreground, I have to then click another widget to finally get the first action to fire. This is probably threading related, like most SWT/Web Start problems but I have no workaround for this problem other than stay away from 7u55. Has anybody experienced this problem and found a workaround?
EDIT: It seems the problem stems from our use of JNA, which we use to get the idle time from the OS using CGSSecondsSinceLastInputEvent. I get a NullPointerException in JNLPClassloader in the logs. If I comment out the code that uses JNA, the problem goes away. Since Oracle seems to be paranoid with security these last months, I'm guessing there is a problem with the jna jar. I sign all jars with the same cert, but maybe there is a new manifest attribute that I should be looking at. Anybody have any ideas?
I'm working on a Java program that is intended to run in full-screen mode. It uses numerous of customized Swing components and Java2D-drawn components that need to be updated and repainted several times a second. And it was working relatively fine on my underpowered work PC.
But then I tried it out at home on my much more powerful PC. And it ran noticeably slower. Triggering an event that should have instantly updated about 20 different screen elements instead caused an effect where each element seemed to take at least a quarter second each to repaint itself. So instead of instantaneous changes it was taking 5 seconds to complete each screen change.
I thought that maybe I was trying to repaint too often or in the wrong manner. But after experimenting a bit with other ideas, on a hunch I let the application start up in a windowed mode instead of in full-screen mode. And with that one change, everything started to work perfectly fast and smooth.
So I suppose there are really two issues here: Why does full-screen mode cause this problem? And why is it only causing this problem on my faster computer? I do suspect there's an OS-related bug. My slow work computer is Windows XP while the home one is Windows 7. I saw in other threads that Aero on Win7 can cause Java speed issues so I tried disabling it. That did cause a small speed improvement but it still wasn't as smooth as when I ran in windowed mode. Has anyone else had performance issues running full-screen Java apps on Win7? And if so, is there a work around?
I found the solution. I stumbled upon Oracle's Java System properties page (http://docs.oracle.com/javase/1.5.0/docs/guide/2d/flags.html) and figured there might be something useful there. While using the trace command I noticed that there were a lot of Direct3D references. Since nothing in my app is 3D, I thought that strange. So I added -Dsun.java2d.d3d=false to my Java command line. As the page says that option will "turn off the Java 2D system's use of Direct3D". And it worked like a charm. Now it runs perfectly smoothly on my Windows 7 machine in full screen mode.