I'm working on a application based on a simple monolithic architecture :rest API backend with spring-boot + frontend with a Js framework.
I have been reading about the headless mode when running java apps and I would like to know if running the embedded tomcat with my spring-boot application in headless mode is a good idea.
Generally you don't need to specify -Djava.awt.headless=true because since around Java 1.8 the JRE determines itself whether a graphics environment is available or not and switches into headless mode if no graphics environment is available.
Relevant source in Java 11: https://github.com/openjdk/jdk11/blob/master/src/java.desktop/share/classes/java/awt/GraphicsEnvironment.java#L166
if you are running a Unix-like operating system and the DISPLAY environment variable is not set the headless is true
on Windows it is assumed that a graphics device is always present and therefore headless is false
In general, running an application in a console requires some sort of terminal to write to.
In Unix-based systems, these terminals are referred to as tty.
This implies the following:
Whenever you open a connection to your server via SSH, you get a tty. Your non-headless application will run in that tty until the tty is closed. To avoid that, you'd need something like screen.
For Windows systems: If you close the cmd window of the console/sign off the user, the application server will also stop running.
That's why productive installations are usually headless and service based.
So much for the background, the official docs actually state the following:
In addition to running Spring Boot applications by using java -jar, it
is also possible to make fully executable applications for Unix
systems. A fully executable jar can be executed like any other
executable binary or it can be registered with init.d or systemd. This
helps when installing and managing Spring Boot applications in common
production environments.
This is described here.
Related
I want to memory-profile my Java application with jvm monitor. All docs seem to assume that your application runs on a server. For example, the first picture on http://www.jvmmonitor.org/doc/ shows an application running on "localhost". But I just run my application in eclipse with "Run as -> java application", so my application doesn't appear in the list of servers.
From the FAQ, linked from the docs in your question: Why can I not find any jvms on jvm explorer?
JVMs started in eclipse are running on your localhost, by definition. It's not that they are running in an app server, necessarily.
You have to contract for supporting non public available Java releases with Oracle for example Java6 ended with 1.6.0_45 publicly but with support you can use 1.6.0_80. Our aim is to stay supported and public available java platform. Therefore we want to migrate our jnlp based RIA application from Java6 to java8 platform. In migration testing we have experienced performance problem. We try to simulate this problem in Java 8 poor GUI performance compared to Java 6 but we realize that the problem not related the that question.
After the introduction, in order to find out the root cause of problem we profiled the application with java mission control(jmc) bundled with jdk. when we profile application launched at workspace we cannot see any performance degradation. And then we realize that problem occurs only JAVAWS environment. Our application runs as expected at java environment but in javaws environment some GUI's are really slow , it adds 6 seconds more to response time.
My first question is that how we profile java application launched by javaws? Because to use jmc we need to set some JVM arguments (java-vm-args="-XX:+UnlockCommercialFeatures -XX:+FlightRecorder") but javaws doesn't support this JVM parameters. You can find supported list at here
My Second question is that why application doesn't run identical at both environment(java and javaws)? We examined signed and unsigned version of our application and both have same situation. By the way our application uses all-permission.
You can pass any JVM arguments you want to javaws by typing them in:
Java Control Panel > Java > View > Runtime Parameters
As for the poor performance, are you referring to application load time? or is it also slow after the applicatio is started?
If you're talking about load time, then yes javaws is slower (about 3-5 seconds slower) because it has to contact Internet to check if your jar files are black listed or if the certificate is expired. I'm not sure exactly what it is doing in these few seconds but I agree that it is disappointing performance hit and I hope someone can shed more light on it.
Thanks Saeid. Problem is determined. We profiled finally and we found that javaws consume long time to load resources e.g. icons, images. to make a solution we cached the resources and for absence images we return a empty image.
You can see this at
To profile application launched by javaws we make a solution following steps in ubuntu
1. move java executable javam
2. create a script file named java and insert following script
#!/bin/bash
/full/path/of/javam XX:+UnlockCommercialFeatures -XX:+FlightRecorder "$#"
3. run application and check java is launched by ps -ef | grep javam
4. run jmc and profile it.
JavaFX 2 is not support Linux yet. Does this mean a client Linux machine (user machine) cannot run it or a server Linux machine (host machine) cannot run it or both?
*EDIT:*
JavaFX is for rich client. So the server will not run it, but store it and client will get it and run it, right?
JavaFx depends on hardware acceleration to run. This is currently not supported on linux (expected 2012). So if your server is executing JavaFx code, then it would not run on the server. If it is only delivering code to clients, like in an applet, then it would work.
It means you can't use the JavaFX libraries on a machine running Linux. Neither a client Linux machine, nor a server Linux machine can use them.
Response to Edit
You can still store and serve JavaFX code on Linux machines. You just can't execute the JavaFX code on a Linux machine.
Note that JavaFX is different from Java. You can still use Java on Linux machines.
I realize this question was posed a while back (11/2011), but I thought it might help to point out the related Open Source project from the OpenJDK community called OpenJFX. Feel free to help out with development, if you're qualified to do so as well. Given the secure nature of Linux, this project should prove a secure/safe way to utilize the "hardware acceleration to run"; though, it's still in the development stages.
Take a look at the project wiki to learn how to build OpenJFX on Linux.
When I run any project java desktop application in netbeans (F6) or run any .jar file java desktop application, it's always delay about 20 seconds or more.
I tested this project on another computer, it works ok (no delay).
Does my computer have an error with Java? Any solution for this problem?
Edit 12/11/2011
Is it true? I check my system, and I think my java application load too much because I can't turn on "Java Quick Starter". It is in Control Panel > Java > [tab] Advanced > Miscellaneous > Java Quick Starter
In my laptop, I can't enable Java Quick Starter.
Thanks for your help!!!
Netbeans will compile your project first, this takes a while. A directly ran java application with a reasonable size jar file should not take more than a second to launch. Of course this does not account for the system you use, if everything you do is slow, so is launching java applications.
Maybe you could try to rise the JVM memory and see what happens...
I think there are 2 params you can give to the Javac to do that they are Xmx( max ) Xms(starting mem)
Or you could try to run jviVisualVM which is a app that comes with java for memory throubleshooting it should be inside java\bin directory
In response to your question about Java Quick Starter. The introduction on the sun website show the following:
JQS is enabled by default in Windows XP and Windows 2000 operating systems and is not necessary on Windows Vista as Vista offers its own pre-loading mechanisms.
and later:
Note: JQS service will perform runtime checks and stop running when a laptop is running on batteries. JQS service will resume when the power cord is plugged in, as performance benefit of JQS is largely dependent on overall system configuration.
Perhaps this is one of your problems.
I am going to create a Desktop application in Java. I don't know whether user having JAVA VIRTUAL MACHINE or not.
My questions are:
I want to know whether its possible to run Java application in a machine that doesn't contains JVM.
If its possible, I want to know whether this case is possible, I will created a application say MyApps, I will to convert this as .exe file and if user clicks MyApps.exe it should run my Java application and install JVM and run in that machine.
Use webstart, and to install java automatically, see the great comment of Andrew Thompson.
Then the user is free to use Solaris, Mac or Linux if he likes.
and updates for the JVM will be shipped to him. You don't need to rollout a new update for every bugfix in the JVM or Java-libs.
You can run a Java application on a machine which does not have a JVM, provided you install the version of Java you need first.
You can create an application which will install java as required and then run your application. However you cannot write this in Java (unless you have a JVM installed already)
This is not completely pointless as many system have some version of Java but may not have the version you need.
Nope, you need a JVM to run the Java bytecode. The only solution would be to transform the bytecode into a different executable format.
Finally I got the solution for running my Java application without Java Virtual Machine, by bundling JRE in the exe file. I did this by using the following link.
It's really working awesome.
JAVA without JVM using Launch4J
If we maintain the Directory Path as given we can get .exe with JRE bundled that will run without JVM.