is possible run spring boot application on backend? [duplicate] - java

This question already has answers here:
Run a command in a shell and keep running the command when you close the session
(9 answers)
Closed 7 years ago.
I have my spring boot application, I normally work with wars that I deploy on tomcat, but I want to try this way a little bit more.
My problem is that when I deploy it in a server, and I do
java -jar target/myproject.jar
Works pretty fine, but after a time without use, the shell gets disconnected and soon after it (I believe because the shell) the process stops.
Any idea how to deal with this?
I am using Debian.
Thanks.

Basically, create a .sh file and set it on /etc/init.d/YOURFILE.sh with the info of this post
Run a Java Application as a Service on Linux
Later just make a /etc/init.d/YOURFILE.sh start and thats it..

Related

How to start JavaDB by Java Program? [duplicate]

This question already has an answer here:
Starting Derby Programmatically
(1 answer)
Closed 5 years ago.
I am using JDK 8, in windows 10. I am developing a desktop based standalone JavaFX GUI application by using JavaDB and Hibernate. I can start the database from Net-beans and it is working fine. But to use the database either i need Net-beans or command line. But when it will be in production then what will happen?
So, i want to know is there any way to start the database from java source code?
I think it is possible because if Net-beans can do it why we will not.
Typically in production DB servers are kept always in running mode.
From the application you just need to connect/disconnect with the db server.
So, I think you must not code to start/stop the db server in production. If you do this it will be a bad design.

how do i run java code in my php script [duplicate]

This question already has answers here:
Run Java class file from PHP script on a website
(5 answers)
Closed 8 years ago.
i have a PHP script which is provide to my one of the friend he is java developer.
that script is on class which is in java language.
i need to run that java program to complete my task. i need to run sum action once in day, and perform sum logical action and updated my data in database everyday.
Please let me know i to do it in php.
here is my java program code.
Run it the way you would run any command line program
var_dump(exec('java yourprogram'));
Perhaps in my opinion the best way would be as follows:
Run your java application on your server with another port (say port 1212)
If it is not needed outside your web server, better restrict the apache tomcat server not to expose port 1212 to anyone outside localhost (you can achieve it with iptables on linux)
Now from PHP, make CURL calls to your java application like http://localhost:1212/my_jar_code.jsp
Use it like web services, problem solved!
In this way your java code will be independent of your php code and you have complete compatibility and power on both java and php codes.

java.awt.AWTException: headless environment at java.awt.Robot.(Robot.java:94) [duplicate]

This question already has answers here:
Using HTML5/Canvas/JavaScript to take in-browser screenshots
(7 answers)
Closed 2 years ago.
I am doing screen recording application in servlet. But its working correctly in localhost with tomcat sever7x. But when I hosted in web server it shows error like this
java.awt.AWTException: headless environment at java.awt.Robot.(Robot.java:94)
Can any one help me? Thanks.
this is not clear to me,
are you trying to capture the server's screen?
as you are using servlet?!
i think its related to display issues on the server
because most servers does not have GUI (Gnome or desktop) as windows for example
so thats your problem
also have a look at this post
Headless environment error in java.awt.Robot class with MAC OS
last post by Ginger Head
This exception is happening because you're using some API that requires environment to support graphics (if saying that simplified). In order to resolve issue you have to either get rid of using classes that requires graphics support, or run it at not headless environment. Try taking a look at line 94 of Robot.java to find out what API complains on headless environment.
You may find these links useful:
What does "headless" mean?
http://www.oracle.com/technetwork/articles/javase/headless-136834.html
I got this problem while running Selenium test(configured to use remote server) on Jenkins. Solution for mwe was to start Xvfb Plugin before the job: https://wiki.jenkins-ci.org/display/JENKINS/Xvfb+Plugin

Desktop browse does not work in java for Ubuntu [duplicate]

This question already has answers here:
Desktop.getDesktop().browse Hangs
(3 answers)
Closed 2 years ago.
desktop = Desktop.getDesktop().browse(uri);
The above code does not work in the Ubuntu OS. If I execute this code, then my application gets struck and hangs for a while and during that time I cannot stop the running application in java console. The only way am able to close that application is by FORCE QUIT.
There are several threads on this issue. I have the same hangs on Ubuntu 16.04. I have posted here the workaround that I'm using: Desktop.getDesktop().browse Hangs
This API depends on the gnome library, you need to have gnome libraries installed for this to work.
Something similar sudo apt-get install libgnome should do the trick i think (do not have my ubuntu desktop at hand to check the package name, try apt-cache search libgnome to find the real name if this does not work).
Note : you should specify which JVM you are using, I assume it's oracle JVM.
You could also give browserlaunch2 a try, yet it's rather old and I've never used it myself. As written on it's website it is meant to open the default browser on the supplied url :
BrowserLauncher2, a continuation of the BrowserLauncher project, is a library that facilitates opening a browser from a Java application and directing the browser to a supplied url. In most cases the browser opened will be the user's default browser.
BrowserLauncher launcher = new BrowserLauncher();
launcher.openURLinBrowser("http://www.google.com");
As BrowserLauncher2 is open source, you could also have a look at how it detects the default browser.

How a java program knows if it has been started by eclipse's `debug` not `run`? [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Determine if a java application is in debug mode in Eclipse
I can start a java program in eclipse by run as or debug as.
Is there any way in the java code to check if it was started by run or debug? I want to do something(e.g. reloading resource) when it's in debug mode only.
Is really eclipse who does the magic, by launching the jvm in debug mode which opens a tcp port to attach a debugger so, if you wish to check if you're in debug mode you'd probably want to check if that port is taking connections, at least is one way I can think of.

Categories