My java application uses swings and makes a connection to the MySQL database. I want to run this application as a windows service which should start immediately at the logon of any user.
I think Java Service Wrapper is useful only for console applications.So kindly suggest me a suitable method.
Thanks for the help!!!
You don't want to have apps with user interfaces as services. Services can start at boot, and if they pop up a panel, they can hang the service waiting for user input with no user to provide any input. Split out the UI from the service code if you want to run the code as a service. Or like Andy mentioned, place the exe in the users startup group.
If you want to create a Windows service, Exe4J makes this easy. It will wrap your Java application in an executable that supports options to install, start, stop and remove it from Windows services.
If you want to start a user interface at the start of a user's logon, you can put the application into the Startup group.
The binaries (e.g. tomcat6.exe, and tomcat6w.exe) that are included with Apache Tomcat can be used to turn a java application into a service. Here's a link to the documentation, which includes instructions for installing your app as a service, etc.: Tomcat as a Windows service
http://kenai.com/projects/winsw works great, and allows easy logging of System.out and System.err.
Used in Glassfish v3.
Related
I have a heavy java web application that has a module which needs to be run as soon as computer starts and 24X7. That module has a bat file to execute which fetches data from server.
I want to run that bat file as a windows service on my system (OS: Windows 7)
I created service with sc create command which successfully created. But when I try to start it, it always give error 1053 i.e. can't start service ; service does not respond correctly or in timely manner.
I followed all the related threads on stack overflow and others as well but no luck.For eg., I set servicesPipeTimeout also but it doesn't work.
Is there a way in java itself to create windows service?
I do not want to use any third party like wrapper, NSSM etc or Time Scheduler either.
Please provide me some clues if anybody faced this error and get it resolved.
Thanks in advance.The time you give means a lot to me. Thanks a lot
What you are trying will not work. While SC will not tell you otherwise, it should only be used to install a binary executable that is already a "true" windows service. Because the batch file does not implement the windows services interface, it fails with error 1053 ("The service did not respond to the start or control request in timely fashion") when you try to start the service.
To start your batch file as a service, use a "service wrapper" -- an executable that implements the windows services interface and can launch your batch file when you start the service. Microsoft's SRVANY is free and basic, but there are also commercial applications more suitable for a professional environment.
I have a web application
hosted by tomcat 7.1
using spring 3.1 mvc framework.
I want to implement a command line function for tomcat console window, to read commands and perform some action or output some information to console. How can I do it?
Example:
type "show memory", then display JVM memory information to console.
Can I do it just by System.in? Will there be any thread-safe problem?
If you're running as a web application in Tomcat, you won't get any access to System.in or the console: Tomcat is typically started in the background, detached from all consoles. And it won't provide you witn meaningful access to the console.
The way to go is to either provide a REST API as suggested by #rlegendi in the comments (any other API would work as well) and write a separate command line application that interfaces with your API. Alternatively utilize the "manager" interface - if I remember correctly from ancient past, tomcat's manager application also has some usable methods to access from external scripts.
Make sure to make those calls authenticated - at least validate that they're coming from localhost so that you simulate some kind of security in the API. Don't trust random calls coming in from the world.
I have just finished developing a REST web service that is consumed by a mobile application. The web service is developed with Java and runs on an Apache server.
I'm now moving to the testing part. And for that purpose, I need to host my web service in a real server.
It is a first experience for, and I just knew that using mutualised (shared) hosting does not allow me to host whatever application, in whatever language.
The one I get to use is OVH, which does not support java web services hosting.
Does anybody have any other alternative to provide. It would help a lot!!
Like I said, if it is for testing purposes you could always use a "normal" PC, running something like XAMPP.
As an alternative you could give RedHat's OpenShift a try, which offers a free, getting-started plan (more info here) that should more than cover your testing requirements.
To run your app (in Eclipse) you would need to : Run As -> Run on Server
And then select a server. If you haven't done so; I suggest you install a local JBoss/WildFly server (the wizard can take care of that for you).
Doing this will display options to run your app either on the local or the OpenShift/rhcloud server.This makes testing faster and allow you to avoid testing on the OpenShift live server.
Where does the application logic run in a Java Web Start deployment? I want to understand the intellectual property security risk of Java Web Start. On the client end does it merely start the application on a server and then proceed to process pixels (GUI objects) and mouse clicks at the client? or is my application logic executing at the client?
Implicit in my question is the assumption that I place no value on any aspects of the design that can be inferred by looking at the GUI buttons, text output and by being an experienced user of the application. The value is in the code and logic.
Java Web Start downloads code to the client, and executes it there. The application logic will execute at the client.
Basically JWS keeps local .jar in sync with that on a server to execute an application in local mode. Read about JNLP here.
So the risk for reverse engineering is the same as with any jar packet Java app.
Basically Java Web Start downloads the latest jars (Application Logic) from the server when u launch it with the help of JNLP. and then it installs this application in temporary internet files or cache.
Your whole application logic(cache) exists in cache at client side. and then your jnlp file use them (jars)
I have a java application which doing some logic... ...
But the java application is only a .jar application. But I would like to let it become an application on the web....I can get the param from the user, but how can I pass the param from user, and put it into my .jar, and process and output the result to the user??
notice that the .jar application is only a console application, which don't need a user interface, only cmd lines communicated with it. Thank you.
Do you have source code? If you do, you can expose the services using JAX-WS annotations. JAX-WS is available in J2SE6.
Take a look at this: http://java.sun.com/developer/technicalArticles/J2SE/jax_ws_2/
You then have to package the modified code to a WAR instead of a jar, because your application now becomes a web application. Then it will have to be hosted in an application server - Tomcat for example.
You may take a look at Metro.