awt & swing alternative for headless environment [duplicate] - java

This question already has answers here:
How to execute Java Swing code in a JSF page
(1 answer)
Creating FacesMessage in action method outside JSF conversion/validation mechanism?
(1 answer)
Closed 2 years ago.
I'm using thirdparty libraries to read data from a card reader (electronic identity cards). I implmented it in my webpage in my JSF2.2 project with maven and it runs on my local weblocic 12.2 just fine.
The libraries use awt and swing to show a GUI with status messages to the user while processing the card (e.g. "Please insert card,...).
But on our server it won't run because the server is running in headless environment. Unfortunately I can't change the servr configuration.
Is their an alternative for awt and swing libraries that I can use to overwrite the UI and that runs in a headless environment?

Related

How to open JasperReports's report on Client Side [duplicate]

This question already has answers here:
JasperReports: How to call the report in jsp page
(6 answers)
Closed 6 years ago.
Im working in a Web application that allow the user to create and see the information from database with a JasperReports's report. The JasperReports works and I can see the copy in the server side.
The problem appears when I want to show the results to client in his computer.
The application send me a java.awt.HeadlessException because of AWT library that JasperReports use.
public void createView(){
jasperViewer = new JasperViewer (reportFilled);
jasperViewer.setVisible(true);
}
Its a very easy code, but I don't know how to fix this problem or its possible to use other libraries.
Some one can help me with other idea or know how to solve this?
This exception occurs only when you run a code in a non-awt environment such as servers. Take a look at link below about the solution.
How do I prevent a headless exception in Java?
If you want to run report in a server environment then show user in a web page you must convert to jasper print to html. take a look this answer for how to do that.
View report using JasperViewer or something else in web application

Java - headless mode - Raspberry Pi [duplicate]

This question already has an answer here:
Run Java AWT/Swing GUI app in headless server
(1 answer)
Closed 7 years ago.
I have a Java Application that runs on a Windows OS, desktop machine with a nice graphical user interface. I updated, modified etc. to get it running on a Raspberry Pi 2B. It just runs about fine. However you would notice that the GUI interface is a bit slow.
On top of that I now plan to run the application on the Raspberry Pi in an optimized mode, where I don't really need the GUI. I was checking many documents about "headless mode", however, I couldn't get a proper answer to my question:
If running my standard GUI application in headless mode, does it automatically take care, i.e. neglect all methods of updating the GUI components? or what needs to be done in order to avoid Exceptions etc.?
Will it theoretically boost performance?
or shall I simply avoid feeding data into tables etc. when running in a non GUI mode?
Best Regards
No, headless mode only means the JVM is stripped of the Gui libraries. You should not use any Gui functions, they are not "stubbed out", they would fail. It emulates only a few things which can be used off-screen (mostly needed for printing or charting)

Check if system/computer has a display or graphical output available [duplicate]

This question already has answers here:
How to detect if a graphical interface is supported?
(5 answers)
Closed 8 years ago.
Update: as marked duplicate, I just want to mention, this seems like a duplicate, but the answer to the other mentioned question is not completely correct. Instead refer to the accepted answer below.
isHeadless would return unexpected true in certain cases.
Its a bit weird situation, but recently I build a very simple java application which can be run in console/terminal mode or in JavaFX UI mode.
However, then while using it on a remote computer which doesn't have any display attached. I got an error that this JavaFX UI application can't be initiated on systems without display, which is pretty obvious.
To overcome this problem, I have been looking for a robust way of detecting if the system has any display attached and it can initiate a JavaFX application, which has to be a platform independent solution, since it could be Windows or Ubuntu/Linux or Mac system.
Structure of the application:
A Main console app, which depending on input arguments executes internally a console app or UI app.
So that, if any arguments given, run in console mode or if no arguments then run in UI mode.
This is where I want to detect if there is a display available from within my main console app, which then won't even try to run the UI app if display is missing.
Any idea how can we achieve this or suggestion in a proper direction would be great.
I think you could use java.awt.GraphicsEnvironment
GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices();
which will return an array with all the available screens. If this array is empty, there is no monitor.
Edit: About using isHeadless(), you can look at How to determine if GraphicsEnvironment exists

How to create remote desktop access application using java? [duplicate]

This question already has answers here:
How can I display a VNC Viewer in a Java rich client (LGPL, Apache, MIT license)?
(3 answers)
Closed 9 years ago.
I have two computer in different network.I want to control one system from another.Both system have windows 7 operating system.Do any one have any idea how to do it??
I don't want to use team viewer or any other application.
VNC has been the most popular choice when it comes to remote desktop/computing. Check out this open source implementation called TightVNC, it even has a viewer application implemented in Java:
http://www.tightvnc.com/release-jviewer2.php
You can install Teamviewer into both computer.
I don't think that have a relationship with java and swing.
I think that you should correct the tags.

How do I determine the default browser in Windows and Linux? [duplicate]

This question already has answers here:
Looking for a Java User Agent String Parser [closed]
(2 answers)
Open a link in browser with java button? [duplicate]
(7 answers)
Closed 10 years ago.
I am designing small Java application and there is a webDriver in it. The application will collect information from a web service.
One of the requirements for this app is no particular browser dependency. That is, I don't know which browser is installed on the end user PC. As a result, I need to use the default browser. How do I do this?
in Windows :you can use browse(URI uri) function in Desktop class ,it launches the default browser to display uri
Desktop.getDesktop().browse("/////URI");

Categories