I am using ui4j library to scape a website, and a button click by emolument.click(), I am getting the following exception:
Exception in thread "JavaFX Application Thread" java.lang.NullPointerException
at com.sun.javafx.webkit.theme.ScrollBarThemeImpl.getThumb(ScrollBarThemeImpl.java:400)
at com.sun.javafx.webkit.theme.ScrollBarThemeImpl.thumbPosition(ScrollBarThemeImpl.java:284)
at com.sun.javafx.webkit.theme.ScrollBarThemeImpl.getThumbPosition(ScrollBarThemeImpl.java:380)
There is a stack overflow post about it, it was solved by page.show(), but since my application is running at headless mode as a background process, I don't have luxury to take on page.show(), I am wondering if possible:
1. catch the scroll event, and ignore it, how?
2. during launching, can I specify the webview reasonable big enough to avoid scrolling? I don't see this option from api.
Related
Hi I'm working on a group project and the code works on my teammate's PCs but I keep hitting MacOS specific errors. And this time I seem to be stuck (no easily Googleable answer).
In a previous post I discovered I need "-Djava.awt.headless=true" as VM setting to properly run my simulation. Now when I try to spawn in some JFrame they are all met with a lovely "java.awt.HeadlessException" Exception because of that VM flag.
Trying to achieve
I want to be able to spawn those JFrames on my MacBook also.
The problem
I need -Djava.awt.headless to be both true and false at the same time for my program to run properly on Mac. Which if I understand my problem correcly, means I have a big problem on my hands.
EDIT: running it in a VM on my Macbook allowed me to run the project properly. This is far from an ideal fix. I'm still searching for a solution to this obscure problem.
What I tried
not running with the VM option: the problem described in previous post occurs. Thus this is not a viable option
running with the VM option: this throws a -Djava.awt.headless when creating a JFrame.
The best way to fix this may be by going back and solving your original problem a different way.
You must make sure that you are not initializing your BufferedImage in the main thread (GLFW thread), it MUST be done separately. It is hard to tell from your original question, but that looks like part of the cause there. Start a new thread to do the image processing instead.
See my solution and recommendation at the bottom of this answer for a quick summary, and also see here for someone else that had the same issue: Java Creating Instance of BufferedImage Freezes Program
A quick note on why your code works on Windows and not Mac: that is because both OS often run different implementations of openGL, and typically Mac can lag behind and miss out on a bunch of updates/changes that may solve problems like this one so that it doesn’t freeze when initializing a BufferedImage on the openGL thread.
If the above didn’t work then lets first look at what headless mode is. (Emphasis mine):
See link at bottom for full article and more info.
Headless mode is a system configuration in which the display device,
keyboard, or mouse is lacking. Sounds unexpected, but actually you can
perform different operations in this mode, even with graphic data.
Where it is applicable? Let's say that your application repeatedly generates a certain image, for example, a graphical authorization code
that must be changed every time a user logs in to the system. When
creating an image, your application needs neither the display nor the
keyboard. Let's assume now that you have a mainframe or dedicated
server on your project that has no display device, keyboard, or mouse.
The ideal decision is to use this environment's substantial computing
power for the visual as well as the nonvisual features. An image
that was generated in the headless mode system then can be passed to
the headful system for further rendering.
So when should headless mode be used:
On a machine that has no display device, keyboard, or mouse.
That is not you is it? However if that is you (LWJGL?), then lets look at how you can work with headless mode:
An image that was generated in the headless mode system then can be
passed to the headful system for further rendering.
This means that you should have a special piece of headless code that does your headless image stuff, but then passes the image back to a normal JFrame with a head.
So why does it fail for you:
Many components are affected if a display device, keyboard, or mouse
is not supported. An appropriate class constructor throws a
HeadlessException
Button
Checkbox
Choice
Dialog
FileDialog
Frame
Label
List
Menu
MenuBar
MenuItem
PopupMenu
Scrollbar
ScrollPane
TextArea
TextField
Window
Solution to the problem:
some classes, such as Canvas or Panel, can be executed in headless mode.
Perfect, so we just need to be careful what is used in headless mode. You asked how you can both use and not use headless mode, well rather than globally setting headless mode with VM option -Djava.awt.headless you can do it programmatically within your code using System.setProperty("java.awt.headless", "true"); where needed. A JFrame should be normal (not Headless), but you can spawn a JPanel as headless without issue.
I recommend:
You create a normal headed main thread with no VM option that spawns JFrames, and then use that main thread to spawn a new child thread and set your LWJGL bits in that thread to be headless, and that way you can run your LWJGL code without issue, and at the same time you can still have JFrames from your main thread. Remember to make sure that the Buffered image is not done in the main LWJGL/OpenGL thread.
Headless info source:
http://www.oracle.com/technetwork/articles/javase/headless-136834.html
I am working on spring tool suite.I am unable to start STS aft regular intervals say in an interval of 0ne week.STS is not getting opened.can anyone please help me to resolve this?
The log file looks like this..
org.eclipse.swt.SWTError: No more handles
No more handles is the issue I've seen on Win platform sometimes. SWT uses native platform widgets and hence every widget created with SWT has an OS/Platform resource backing the widget. On Windows this backend resource is called GDI handle or GDI+ handle. If these resources aren't disposed correctly by Eclipse or any other app on your platform you'll eventually get "no more handles" error.
Fixing this such that you could start STS would be to restart the machine i guess.
You can also try increasing the number of handles in Windows. (There is plenty of posts about that. Here is one: http://weblogs.asp.net/mikedopp/increasing-user-handle-and-gdi-handle-limits)
The real issue however must be an application that doesn't dispose GDI resources. For Eclipse application every SWT widget must be disposed at the end.
As stated in the title, my software won't launch unless the "Show console" option is selected in Java settings. I'm not sure what kind of code you'd like me to post, so please ask.
When I try to run it, the Java dialog pops up and the progress bar that loads the software completes before it closes. When the console is up, the software finally loads and displays afterwards. Without the console, nothing happens.
I've tried to run the web start on different computers, and they all had the same problem. The console doesn't print out any error messages, so I don't have anything to use for debugging the problem.
Some information about the software:
It's a JavaFX project, compiled using Oracle jdk 1.7.0_65 on OS X with Netbeans. It requires full security permission, and all jars (I use a bunch of libraries) are being signed using a key store from a trusted vendor.
EDIT
I tried to launch my program through console using the following command: javaws -viewer http://www.website.com/software.jnlp, and - without launching my software - it returned the following result to the terminal:
java.lang.NullPointerException
at sun.awt.SunToolkit.getSystemEventQueueImplPP(SunToolkit.java:1003)
at sun.awt.SunToolkit.getSystemEventQueueImplPP(SunToolkit.java:998)
at sun.awt.SunToolkit.getSystemEventQueueImpl(SunToolkit.java:993)
at java.awt.Toolkit.getEventQueue(Toolkit.java:1749)
at java.awt.EventQueue.invokeLater(EventQueue.java:1245)
at javax.swing.SwingUtilities.invokeLater(SwingUtilities.java:1290)
at com.oracle.deploy.update.UpdateCheck.updateStateChange(Unknown Source)
Could this be of any help?
For others who might have this problem, this is what caused it for me:
I had a thread running in the background that would show the stage once it was done loading all the assets. This stopped the whole thing from executing, so I had to change the loading logic inside of my code instead to allow for the primary stage to use the show-method in the UI-thread.
Whenever I use my webcam application within the main form, the program does not closed and still appearing in the task manager or in the bottom right of the Netbeans saying that it is still running even if I clicked STOP or close my form. It only occurs when I access my Webcam snapshot application from my main form button.
I've read so many answers but it doesn't give me the solution.
My guess in my problem is the following:
It is still running because it will not terminate unless all non-daemon threads (my webcam thread?) are closed.
OpenCV libraries' fault?
Please refer to my first stackoverflow question link : MY PROBLEM.java
Thank you,
I'm using uiBinder and if I want to have Google Maps widget and suggestbox on the ui template I just get blank screen with nothing loading. Everything compiles OK. I have tested all the permutations in all the important browsers and it is the same thing everywhere.
Any idea on how to approach this in order to figure out what is breaking the javascript?
It possibly sounds like a runtime exception has been thrown before any UI controls were rendered.
As a simple test make the very first line in the client be a Window.alert(). If you get an alert box then run the app in the GWT Shell to see the ex stack trace. If you don't get an alert then the GWT app isn't loading. Try running in Firefox with FireBug's Net monitor enabled. This should let you see why the relevant JS files, etc aren't being loaded.
Having a nocache.js in the .html page that doesn't match the project creates a white screen. Try this if the alert code mentioned in this thread doesn't work.