How to install mysql dynamically from within java? - java

I am currently trying to create an installer for a application that i created. And i want the installer to be able to run on mac, windows and linux for now. Hence, i chose to make my installer in java.
Now, the problem that i am facing is i have to install mysql from within java without giving the user all those unnecessary choices during the setup phase because it really necessary for them to know it. I know this can be done because while installing wamp, this is how mysql is installed. I only need to bother the users for the right things.
So, can somebody tell me how it can be done?
Thanks in Advance

For Mac and Linux I would let your installer start a shell script. However on Macs it is not common to have "installers". You should consider to just deliever binaries which the user can copy via drag&drop with his mouse. For that you usually only make an immage file (*dmg) which gets mounted by the finder and opens in its own finder window. You can have a symbolic link of the Applications folder on that *.dmg and a background image with some text: "drag here --->"

This might not be exactly what you're after, but how dependant are you on using mysql as the DBMS? If you use fairly standard SQL and this suits your application, maybe you could switch to Apache Derby? That will allow you to include the whole DB as a part of the installation, and completely invisible to the user.
See: http://db.apache.org/derby/
(caveat: I don't remember the details of the Apache license, but I'm assuming there's no issue there)

Related

Run Jar file on startup?

I have a Java application that lives in the system tray that I compile to a executable jar file. I would like to add the option within my program to add to the system startup items.
As I do not know of any uniform way to do this for all operating systems I assumed I would have to write code to do it for each one I intend to support so I started with Windows.
When I attempted to add it to the registry at [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run] using the code available here I discovered that under Windows 7 and 8 unless I have administrator privileges (by running from an elevated command prompt) my edits to the registry do not apply.
Then I spent a day trying to figure out how to get the Jar to relaunch itself with admin privileges before I gave up on that hacky workaround.
Can the task I'm trying to achieve even be accomplished and if so how?
For the most part, you're actually looking to add the feature of auto starting on user login, rather than on system startup. For windows, if you add the registry entry under:
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run
This location does not suffer from permissions issues when run as an ordinary user, and has been supported for a long time under Windows (I'm thinking Windows 95 time frame here), so should be a safe change across all systems.
For Linux, assuming that the operating system is following the Open Desktop AutoStart specification, then you need to create the appropriate .desktop file in $HOME/.config/autostart/ and it should autostart on login in that case.
For Mac OS X, you need to create a launch agent plist in $HOME/Library/LaunchAgents. The Daemons and services documentation details how to construct this file.
Working around user privileges is not a good idea. The registry entry is the preferred way to go. Also keep in mind that the jar by itself is not executable, it requires the jvm, so what you might want to do is use a wrapper and register that.

User of having multiple JREs in Control Panel Java Applet

Can anyone explain the use of having multiple JRE's in the Control Panel Applet of Java?
Refer to attached snapshot http://ge.tt/5YRkjNm/v/0?c of the location i am referring to.
An applet or desktop app. deployed using Java Web Start can request a specific version of the JRE in the launch file.
Different JREs have different compatibility issues. Code that worked on an earlier version of java may not work on a later version. Also, if there's multiple JREs, it may be hard to decide on one to keep. Thus, it's best to let the user choose.

Installing java program via CD

I have a program (java jar file) that I want to distribute on CDs. My friend told me that there are free/open-source CD installers available that automatically install your program onto the customer's computer.
Now I can't seem to find this on Google. So are there any CD installers that you would recommend that I can use (so I don't need to program one myself).
Outline:
My program consists of class files, sound files, source files (i'm open source) and images (packaged into a jar file).
I only need the installer to work for Windows computers.
I think IzPack does something like that.
You can look into Java WebStart which in Java 6 was enhanced to allow "launch-from-cd-and-install-to-harddrive" which mean that it can work as a very simple installer.
It requires a JVM already present. You can put the redistributable JRE on the cd too.
Launch4J is what I have used as my installer. It is really lightweight and has a nice GUI that makes things simple for the developer (one reason I chose not to use IzPack).
It makes things dead simple for both the developer and the user.
Your jar file is wrapped in a exe launcher.
If an up to date JRE is not detected, a bundled JRE is used or the user is prompted to download via java.com/download
Really, I couldn't have asked for anything simpler/better. Although you might get more functionality out of IzPack, if you want something dirt quick that can do everything the everyday developer needs, go for Launch4J.
P.S. Their splash screen option is a nice bonus :)
After running into numerous end problems, I finished the job with the use of Inno Setup.
Very quick and easy to use. Creates an installer similar to the ones you would see in popular programs. Gives you (and the user) the ability to create Desktop Shortcuts, QuickLaunch Icons and Startup folders. Allows you to add license information etc. Very simple and intuitive interface, I didn't have to read any documentation!
A big con: Only makes installers for windows. That met my requirements, but may not work for everyone.

Demo Java application runnable from a DVD

I wish to give some demo copies of a Java application on a DVD to a client. Does it make sense to have a preinstalled JRE and Java application on a DVD so that they can just click and run it?
Also, if anyone has done this what are your views on this?
I would suggest you skip the DVD and go for a flash drive instead. This way you can use portable Java and run your app from the flash drive without having to install anything on your client's computer. With the low costs of flash drives these days you should easily earn back what you spend in money in convenience and time.
Here is a tutorial that shows you how to set this up.
Indeed you can simply put a JRE into a directory of the DVD.
Then you start the application with a .bat file that runs a command such as :
jre\bin\java.exe -jar Main.jar
(If your jar and the jre folder are in the same directory)
Be careful about one thing : you can't know in advance what the DVD's drive letter will be, so in your .bat file you must give relative paths to the JRE and to your jar (or starting class).
If you are dealing with a one or two people then just throw a JRE on the DVD and explain how to install it or even just include a link to the page where they can install Java themselves. In the past when dealing with a large set of recipients that needed to install a JRE and run an application, I have used tools like InstallAnywhere, to create a simple setup to walk the user through a wizard for setup.
I've in the past copied a windows JRE directory to a USB flash drive, and run a java app off that.
If:
The users have an internet connection
The demos. have a GUI
You can deliver them off a site
..I would recommend using deployJava.js to ensure a suitable minimum JRE, & Java Web Start to download/install & launch the demos.
JWS has a number of advantages in this situation:
Server hits for the resources will reveal what proportion of the people to whom the demo. was delivered, are actually trying it.
JWS offers 'lazy downloads' so that if a potential user is only interested in one small section of a large application, they do not have to download the entire binary.
If the user turns a demo. into a registered version, (at least parts of) the app. will be already installed.
But in the event that it is a constantly changing app., JWS will automatically update any new parts of the app.
All this is part of the 'one click' installation experience for JWS. It is more tricky for a developer to set up, but once done well, is a breeze for the end-user.
You might include an HTML page on the CD (DVD would be a waste for a single HTML, a couple of images & some CSS based style sheets) that links to the demos. But since the hardest thing about getting a user to try a demo. is getting them to put the disk in the drive, I would side-step the disk entirely & send the 'Here are some free demos.' HTML to the user as email.
This was included as a comment a couple of days ago. Since the thread was resurrected, I decided to include it as an answer & expand on it.

How do I create a Mac installer for my Java application?

I have created an executable JAR file for my Java application. If I double-click then it works fine. But I want to create installer for Mac OS, because I cannot give a JAR file to my users. Any suggestions?
Well, all you have to do here is to create a beautiful icon for your app, bundle it to your jar file to make it look more sophisticated, instead of using the default coffee cup icon.
Here is how you can do it:
http://www.centerkey.com/mac/java/
Please read the sessions starting from session 7.
Mac has java by default. And if your users are not technical, it makes no different for them if they are using a mac .exe or not, right?
Just a comment to clear some of this up. Mac applications normally dont have installers. At all. They dont have a registry and normally you just drag the icon (which is actually a folder with the executables in a specific folder structure) into the applications folder. Thats it. Thats why if you have an executable with a nice icon and you put it in a .dmg image file nobody is gonna know the difference.
I'd agree that a jar should be sufficent; but maybe you want to check this (ClickInstall MacOSX 1.0.2) Installer Build Tool for OSX.
The very first hit on Google for "Mac Installer" is the Wikipedia article about the Mac Installer.
You can click through from there to read Apple's Software Delivery Guide. It tells you in exhaustive detail everything you could possibly want to know about this.
Please, for your own good, read up on How To Ask Questions The Smart Way. You'll get much better results that way.
Try jarbundler from http://informagen.com/JarBundler/.
You can create a nice OSX app including icon with it.
Just ship that. The user can drag this app to Application. No explicit installation step
necessary.
I use this for my projects.
Well, if this is what you looking for, How to Create a Mac Installer for Java Application
give a try, many could help.
This works for me: https://github.com/Jorl17/jar2app
For any changes made in code, I just need to move updated jar file in the folder application.app/Content/Java

Categories

Resources