I have an Applet and when I try to run it on my laptop, a headless exception is thrown by Java at the line where a JFrame is created. Now I know why the JFrame normally causes the exception but my computer was not in headless mode to begin with. I'm also still not sure what headless mode entails exactly.
I'm running Ubuntu and have a pretty recent version of java.
Also, I have successfully created JFrames and such in Eclipse when running Windows on my laptop (if that helps).
Have you tried setting java.awt.headless=true? I have done this once before on Solaris with no x-server in order to use the java.awt print libraries. It worked a treat. However it was more than five years ago and I don't have the source handy.
See Setting java.awt.headless=true programmatically
PS Are you on Ubuntu server or desktop? If the latter, I'd question why Java thinks you are headless.
Look # following link that might help:
http://www.theserverside.com/discussions/thread.tss?thread_id=52535
Related
I met a bizarre issue on my working laptop. Usually, I use my desktop PC for work, but I am in the office today. I am using my working laptop. For some reason, I cannot copy from Windows 10 to JMeter and from JMeter to Windows 10. For example, I am using Notepad++ for creating test cases for interface testing. I am trying to copy-paste from Notepad++ to JMeter. It is not possible.
Something that is very strange for me is that JMeter window has some strange green line at the edge of the window.
I am using JMeter version 5.5
Windows 10 - 64 bit
I tried with JDK 17.0.1 and JDK 1.8_202 (because I wasn't sure if the issue came from Java at all)
I don't think it's connected with JMeter by any means, most probably it's some form of antivirus software which prevents clipboard actions somehow.
You can try increasing JMeter's logging verbosity to DEBUG level just in case and see if there are any suspicious entries in jmeter.log file, however I'm more than sure that the behaviour is caused by some 3rd-party software running on your laptop, if it's not the antivirus it could be something like WRITEit application so do a clean boot and the issue will go away and then add the startup programs and start services one by one unless you detect the one which causes this problem
I had the same problem with JMeter 5.5 when I had changed Option->LookAndFeel->"Metal". Then I returned back to "System" and the problem had gone. Now copy-paste are working well.
I find the solution.
#Dmitri T was right. The issue appears because of antivirus protection. The fix was to run the jmeter.bat file as an administrator.
I just wonder something about java applet with awt. I quite disappointed with this problem and want to throw it away sometimes. Below are my descriptions:
I already created one application using java applet with awt controls on my own computer, let's say computerA using Window 7 32bit Operating System. To up and running this application, I update java version to the latest one.
Application is working fine with computerA. However, this application also need to run on the others as well. As my own situation, I run with another computer, let's say computerB using Window 7 64bits Operation System. I knew that the application created with 32bits java version, thus I decided to install this java version on computerB. However, when I run the application it can only display interface on browswer, but some of its function did not work.
Yet I didn't throw it away, I decided to configure in the last computer, let's say computerC. This computer use Window 8 32bits Operating System. I did configure as I did with computerA and computerB. The result is still exact as computerB.
I also checked up this solution on here, but it is not fit my problem.
Here are my questions:
What is the exact problem on here?
Where does the problem come from?
Is it solvable?
How can I solve this kind of problem? Any helps?
Update:
PostgreSQL Database also install in other local computers as well.
I noticed that If I convert my code into eclipse project, it worked fine. No problem at all.
Thanks in Advance.
I'm running MATLAB 2013b on Ubuntu, and I'm having many problems with the display of windows. For instance, when I try to start GUIDE (typing "guide" at the command prompt), I get just an empty rectangle.
Looks like some kind of incompatibility between MATLAB, Ubuntu and Java, but I'm not sure about how to proceed... any ideas?
... well, just in case somebody comes across the same problem, I'll leave my answer: it's just a question of giving up Unity in Ubuntu and start the session with the "classical gnome desktop (no effects)" option.
I'm running Ubuntu 9.10 and trying to run a Java program I wrote whose source code is located on a remote machine. I'm using ssh to connect using the following command from the terminal:
ssh -X username#hostname
When running the program, one of the GUI frames has its buttons missing from view, but they are clickable and work as expected when I can guess accurately where they are. Running the code from my local machine they are present, and running from another windows machine using X-Windows they are present. Been trying to solve this problem for a few hours now but to no avail. Anyone have any helpful insight how to resolve this issue?
Thanks!
Are you using both Java 5.0 Swing toolkit and Compiz window manager? They tend to not like each other. Try use Java 6.0 or temporarily disable window effects.
I am using Tomcat 5.5.23, JDK 1.5 on HP Unix. We have an application which when invoked form tomcat starts an applet. It was working fine till JDK 1.4. But now we have moved to JDK 1.5 and the applet does not start. The exception thrown is -
java.awt.HeadlessException:
No X11 DISPLAY variable was set, but this program performed an operation which requires it.
I then added JAVA_OPTS="-Djava.awt.headless=true" to catalina.sh file. But still I get the same Headless exception, but this time without the X11 Display message.
Any help would be appreciated.
Odd.. you're trying to run an applet (I assume you are talking about a subclass of java.awt.Applet) inside tomcat? Generally this won't work because there's no display on which to display the applet.
Assuming you don't want the applet to display anywhere and you just want to execute some portion of it programmatically, you may be able to get by using a virtual X server such as Xvfb or Xvnc. Once you have Xvfb or Xvnc running on your host running tomcat, you might try to set the DISPLAY inside the tomcat startup scripts to use the display of the virtual X server.
-Djava.awt.headless=false
add above in your Tomcat startup script. it will work 100%
You are maybe using something in your Java code that can not work on a headless system, such as graphics components (Swing objects, images, etc.). Some of these components, instead of being directly handled by Java, are handled by underlying platform (Windows kernel itself or X-Window server on Unix). This way the overall performance of application is boosted.
So the question now is, ok if it was working on Java 1.4, why doesn't it work on 1.5? My bet, given the peformance boost since Java 1.2 that Swing has received over time, is that Sun has moved the management of some graphic objets to OS level to increase performance. So if you can not stick to 1.4, then you should revise your code.
This good article will help you understand how to modify your application to make it headless-friendly.
Applets are going to have a hard-time running server-side. They are designed to run inside of a container, such as a web browser. The exception is getting thrown most likely because the applet is trying to draw it's GUI -- and the server is providing no support for this. I'm surprised that it worked in JDK 1.4 -- I don't know what changed between the two revisions which would have affected this.
You may also have to install the x11 libraries, or at least explicitly export the path to them.
/usr/X11R6/lib
Open $CATALINA_HOME/bin/startup.sh file with your preferred text browser
Paste this line export CATALINA_OPTS="$CATALINA_OPTS -Djava.awt.headless=false" at the beginning of the file
Save and close the file
Restart Tomcat
In spring boot with database access, when you specify asterisks: **** as username and password, it will try to prompt the user for a username and password (you read that right), and it will throw this HeadlessException if it's not a gui application.