Programmatically adding Java app to startup - java

We're making a login client in Java for a school project.
It uses SSH to connect a local server to allow for internet connection, for the convinience of our users we would like to be able to make an "open on startup" function.
We know that this could be done by cron/damon jobs in linux, and by service/registry methods in windows... We don't know about OS X.
We would like to CODE the solution in java, each solution doesn't have to be for all 3 OS' but just one, then they can execute when needed.
Any help would be appriciated. :-)
Regards
Martin

YAJSW (Yet Another Java Service Wrapper) could provide this functionality, and is licensed under the LGPL.
http://yajsw.sourceforge.net/
You'd want to create your configuration during installation I suppose, and in install/uninstall the service when the user toggles the checkbox.
You'll also find a feature matrix of other options for achieving the same thing at http://yajsw.sourceforge.net/#mozTocId284533
And for you interest, under the hood on OS X the system this uses is called launchd.

You can try the Java Service Wrapper, which also support launchd on OS X. Furthermore run a Java application as Windows Service or on Linux using init.d/upstart.
http://wrapper.tanukisoftware.com/doc/english/launch-nix.html#boot
http://wrapper.tanukisoftware.com/doc/english/download.jsp
Please let me know if you have any further questions.
Best Regards,
Chrisitan

Related

Installer for Java Spring Boot service

I have a Java Spring Boot application which I would like to run as a service, ideally in Mac, Windows and Linux. It should run 24/7 and be robust i.e. restart itself if it crashes.
Does anyone know the current best practice way of achieving this?
In order to make an app as a service it should confront to some Interface defined by Microsoft. Here it is:
https://msdn.microsoft.com/en-us/library/windows/desktop/ms685942(v=vs.85).aspx
This is not the easiest solution and will make you app platform dependent. There are some wrappers that make what you want possible.
Check the Java Service Wrapper
https://wrapper.tanukisoftware.com/doc/english/introduction.html
It has options to wrap the app as windows service and unix daemon. I am not sure about macOs. There are other similar wrappers too
Best practice1 is to use the best practice solution for each platform. Unfortunately, that means different things for different platforms; e.g.
on Window, use the Windows Service mechanism
on UNIX / Linux, write a service script that uses the distro's native "init" framework
on Mac OSX, you typically use something like Automator to create a ZIP file that implements the service.
Unfortunately, in the UNIX / Linux case there are a number of different init frameworks, depending on the vintage; see this Wikipedia page.
Another answer mentions the Java Service Wrapper. I don't know how well it works with different Linux "init" frameworks, but it looks like it provides a one-size-fits-all init script written in "sh". It should be usable with systemd, though you won't get the full benefits of that framework.
1 - But read James Bach's No Best Practices article.

How to integrate java with control M

I have few control-M job running on server. I can perform basic operations like to start/stop or pause any JOB from control M Interface.But there is not a development environment available for Control-M.
I have another java application from where I want to start/stop/pause and other basic stuffs of Control-M.
Till now I am totally blank.I don't know which JAVA API, I should use. Do i need to have development environement of Control-M also.
Could some one please help me on this regard?
You should use Web service functionality of Control-M.The details Example is given with API. Run the bat file for configuration.Provide your parameters.Run ClientGui.java.
if you have provided your correct parameters than you should be able to connect with control-M.Please make a comment if you are facing any issue..
Look at Control-M for Web Services, Java and Messaging. They also just came out with a Automation API but you have to have Version 9 Fix Pack 2

Remote desktop control using web application

We are planning to develop remote desktop sharing feature in out web application (written in Java) where one user will be able to connect other users desktop with full access.
I don't want to use applications like team-viewer. It has to be some kind of web browser plug-in or feature.
I found following couple of solutions like Adobe Connect & Java.awt.Robot class.
Can anyone please let me know best option available?
It will be great if there is any open source project which can satisfy these requirements.
Try RealVNC out of the box, it has a built in Java web-client that allows full control. Most of the standard flavors of Linux run it, this, of course, totally depends on your user base and what you're trying to do but for an internal tool it is perfect.
http://www.realvnc.com/products/free/4.1/man/vncserver.html
The above link is the documentation for VNC server. It can be configured to one-session per port, it is just a matter of making sure the ports are correct. It sounds like you're reinventing the wheel on this one. There's a horde of good free products out there to handle this. For an infinite user-base this probably wouldn't be the best solution. For an internal tool it works wonders.

Create an installer in Java

I want to create an installer using Java that install at first MySQL. The user tape at first the password of root user. Then the installer copy jar file into program files and create shortcut on desktop.
So my question how to install MySQL automatic via Java. Is there any way??
Thanks in advance.
best regards,
Ali
Depends on the platforms you want to install onto. Basically if you know how to do it via the command line, then you can write a shell script that is executed from Java, or a series of command line statements that are executed from Java to do it.
Since you mention root user, I'm guessing some flavor of linux? Doesn't MySQL already have ways of doing this that come with the installers and/or binary distributions?
This write-up might help you in creating a java installer: Convert Java to EXE (also has information about other platforms)
But, before going for that, I would like to ask you, why do you want o bundle MySQL with your java app? The recommended way, if you want a DBMS bundled in your app can be:
Ask the user the install MySQL him self. You app will use it.
Use SqLite (embedded RDBMS). Or even simpler, Berkley DB for a Key-value store. This approach will be super light and no installation needed.
You can try to perform a 'private' ad-hoc MySQL installation that is only used by your application: that means you will have to copy the binaries (please note they are different for each platform) plus some custom configuration files to a 'mysql' subdirectory of your programs' main directory.
I can assure you it won't be easy and fast to do. You have to struggle a bit making it work under each platform. This kind of stuff is always a bit tricky.
If you prefer to install MySQL in a system-wide manner (as a service, using the provided install package) you'll have to embed the package into your setup program and then use the proper operating system commands to install it. That would be different on each platform, and under Linux you'll have to install the proper package for each distro. Messy.
You can look at some commercial solutions for making Java install programs. See install4j for example.
Shipping MySQL with your Java application is not so easy. Are you sure you need MySQL, and you cannot use some simpler alternatives, like sqlite? If you choose sqlite, there are some 100% java solutions, and that means no difference between platforms and easy deploy of your application.
Think about it, listening to this simple advice can make you save 14-15 hours of work and debugging (with always some possibility of failure, because complex installers do fail).

How can I provide a telnet interface to my Java application?

I want to provide a telnet interface to my Java application, primarily so that developers can interact with the app, view debugging information, etc - before we've implemented our full end-user facing GUI.
Can anyone recommend an easy and effective way to do this? I've looked at embedding the scala interpreter, but it doesn't seem to be accessible via telnet. Ditto for Beanshell (which I'm not too keen on anyway as I believe its unmaintained).
Couple of options:
Grizzly for embedding a generic server (http://grizzly.java.net/)
Mina is another similar option (http://mina.apache.org/)
Instead of Telnet, it might be easier to just embed a web server. Not that a CLI isn't cool and all, but it might be a bit easier/more friendly.
Jetty http://docs.codehaus.org/display/JETTY/Embedding+Jetty
Tomcat http://tomcat.apache.org/tomcat-5.5-doc/catalina/docs/api/org/apache/catalina/startup/Embedded.html
JMX is great for monitoring but the UI isn't very good for 'writing' data. NetBeans has some nice tutorial projects in it.
I think of all of the options above the embedded Jetty is probably the easiest.
Have you considered using JMX? It's built right into the jdk and can provide remote access via jconsole to any methods you configure it too.
Now it's not going to work exactly like ssh or telnet, so it might not meet your needs fully. But if your goals is access to invoking methods and debugging information remotely, that's kind of it's main purpose.
The bonus is after you build a UI you can still use the JMX stuff to monitor performance after it's goes live.
Try Jsh its good for telnet related stuff.
I faced this same issue and came up with a slightly ugly combination of nvt4j (telnet server code) plus JLine (Java command line history editor, tab completion, etc.). My application listens on localhost for telnet connections and runs a CLI console loop when it gets a connection.
One key trick is to get the rows and columns information (which is sent via the telnet protocol) transferred from nvt4j to JLine so things don't go haywire when you reach the end of the line.
If you only need a line-mode interface via Telnet, you could use my Java class TelnetStdioRedirector.

Categories

Resources