Create an installer in Java - 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).

Related

how to make program able to install

I have finished developing my java application using netbeans. Now I want to give it to others. How can I change it so that user can directly install and run my application without having to run it from IDE or command line.
Thank you
You have a few options:
If "install" means an icon to click on and run your app, you can create an installer to do so. You don't specify your target operating system. I'd recommend Googling for installers like Wise.
You can create an executable JAR with a launch command file for users to execute.
You can use Java Web Start.
You'll have to assume that your user base has a JVM of the correct version installed and available for your app to use.
You don't say anything about databases or other services, so I'll assume that you have a main method that you want to launch.
For a simple application with no dependencies, the easy way is to create an executable JAR file.
For a complicated application, you need to package up the primary JAR and the other things that it depends on, and present that in a way that the user can install. This might be a simple ZIP file (or equivalent) for the user to unzip. (That is the way that Eclipse and is distributed for example). Alternatively, it might be a fancy installer ... which you would need to write or generate. (There are a variety of installer generators out there: some free / open source, others commercial.)
Basically, you need to balance "ease of installation" for the user against the amount of effort (and money) you are prepared to spend on creating installer infrastructure for your application.
Alternatively, if you are prepared for the application to be hosted on and launched from a web server, then Java WebStart is a good alternative to an installer, not least because it removes the need to get the user to reinstall to pick up newer versions of your application.
Look into some free packaging installer like presented in here.
You should understand how your application should be setup on a "clean" machine and describe it to the tool you use.
I've used IZPack in the past and am very pleased with it.You will also need to know how to package your app into jars/wars/ears (or other).
I hope this gives you a staring point.
You can give JSmooth a try and see how it works for you. I haven't used it before but a co-worker of mine has several times and he seemed to be happy with it.

Installer for Java Desktop Application

I am developing an inventory system i-e a java desktop application. I am using Ms Access as database engine and there are certain modules e.g one makes reports using ireport and other such dependencies. I need to ask how can I make installer for my application which will install few fonts, copy database files, install jre to make it run etc. Please guide me in it.
Thanks in anticipation.
This is something I've briefly used in the past, and it may serve your needs. It's an open source installer builder system, tailored towards Java apps.
http://izpack.org/
I've used jsmooth which creates a single EXE-file that unpacks and run transparently. Not a full installer but worked well for us.
Note: I have not seen any Java installers which asks the "There is an update available. Update now?" question.
If this is important to you, then consider Java WebStart which checks for updates at each launch (but do not ask).

Java Desktop application

This is a single question, but with a couple of sub questions. I am planning a Desktop application using Java and I am using NetBeans as the IDE. Questions:
Why are there so many versions of Java? Java, Java SE, Java EE, Java Me
I want the application to store data locally, what is best Java DB or SQLite?
Do I need anything extra to create a setup file for my clients to install the application?
Is it there a Java solution similar to .Net OneClick to keep the clients updated to the latest version of the application?
I have plan to run the application in Windows, but if I have to ported to Mac or Linux how hard can it be?
There are different java libraries for different purposes. Java ME for instance, is designed for cell phones / mobile devices. You'll probably be fine with java SE, unless you need some of the features from EE.
Depending on how complex your data storage is going to be, you may not even need a "database." In java, any object which implements the "serializable" interface can be written directly to a file. So, if you're just trying to store things such as user settings, etc, you can create an object to store them, implement Serialiazable, and write it to disc.
Only if your application links to code libraries which you don't want packaged in the same directory. You can package it as a self-executing JAR from netbeans, it'll be similar in function to an .exe
(Shrug.)
If you are careful not to use operating system specific paths, a self-executing jar will work immediately on any operating system with the JVM installed. There may be a couple other quirks, but Java is built to be extremely portable.
Because you don't really need everything everywhere. For example you don't really need to use GPRS or SMS from you computer, or ORM from you phone. Each edition is targeted to a specific environment. This way you can have a lighter environment for mobiles, and a lot more components for enterprise applications (which you don't really need of a standard application).
I would advise you to use JavaDB (or Derby) but it really depends on you
Not really, you could offer a nice solution to install your application, but it's not necessary.
There is (I don't remember, but other answers will certainly help)
It's really easy, in particular for unix application, the executable creation will basically be a .sh file launched directly (you could of course have a real executable on UNIX, but it's really common and easyier to maintain to have .sh files) (you could also use .bat file on windows, but let's say that's just less common)
I re-read the question and might have not really answered the last point (I was still on .exe creation) so here is a second shot :
5.It's the main goal of java, to be ported everywhere. As long as your code doesn't use specificity of your system (or it's protected with ifs) your code will work everywhere. Of course you have to use the same java edition (edition, not version) and the same libraries or you could have problems.
Why so many Javas? Java, Java SE, Java EE, Java Me
So many environments. The first two are desktop, EE is server side, ME is phones.
..3. Do I need anything extra to create a setup file for my clients to install the application?
Use Java Web Start.
That also covers 4. & 5.
I have no opinion on which is the 'best' DB, but note that for small amounts of data, JWS provides mechanisms where even sand-boxed apps. can store and retrieve information, alternately the installer-desc element can be included in the launch file to install/set up the DB.

Compiling and Executing Java Remotely

If you do not have Java installed in your computer, is it possible to compile and execute Java programs by pointing to a PC which has?
If you have Java installed on your machine then zip that whole directory and give that to those guys. They can extract it to their machine, they don;t need admin rights for that. Thats it you are done and can use javac and java to compile and run. You can add the bin directory to your PATH then you can executes these command from anywhere.
Also you can login to a remote machine where JDK is installed and the logged in user have execute permission.
Dude, you have an organizational problem, not a java problem. If the higer-ups don't want programmers hacking on the regular boxes, then you really shouldn't be trying to bypass the protection. Way to get in serious trouble.
Do it the right way - speak to someone with the authority to get the jdk & eclipse (or netbeans, if you insist) installed.
As a last resort - anyone who wants to learn java will have a home PC or a laptop. Just remember, if you have to use your home PC to learn java, then you owe your employer nothing by way of loyalty or obligation to use your new skills working for them.
If they are able to log in to a PC which has the JDK and JRE installed, then they should be able to compile and run their Java programs from that PC. It shouldn't make a difference whether they're logging in remotely or locally. Java can be run remotely in much the same way that any other program can be run remotely - although exactly what that way is probably depends on what method of remote login is used (SSH, remote desktop, etc.).
Theoretically, they could use a remote desktop solution like VNC to compile and run their programs on a different computer, but it's going to be sluggish and uncomfortable to use, probably giving them a bad impression of Java. Besides, if your company's IT policies are as paranoid as it sounds, you'll most likely never get the permission to run a VNC server.
It would be much better to lobby management to have a JDK installed on these people's PCs. Stress the value of their emplyoees acquiring new skills.
If the company is dysfunctional enough that this is not permitted, seriously consider getting a job somewhere else.
yes, check out Java6's The Java Compiler API. It allows you to compile code given in string and has nice error support.
This will be very painful for them to use going forward. Couldn't you get the JDK installed?
As described in another answer, you should be able to copy a pre-installed JDK to the local drive, just setup a batch file to setup a JAVA_HOME and add to path.
You can also copy Eclipse locally - you don't need to install it.

Matlab in a Chrome extension (via Java compiler) possible?

Is it possible to integrate a Matlab program into a Chrome extension using the Matlab Builder JA?
Essentially, I have a computational tool in Matlab that I want to make more user-friendly and widely-available for other researchers with few or no programming skills. The best way to do this seems to be deploying it on the web--and, since I don't have access to a web server, in a Chrome extension. In order to deploy Matlab on the web via Java, it seems I need to upload the JRE or JDK and do a lot of other configurations on a server, like in http://www.mathworks.com/help/javabuilder/web-deployment.html (need a Matlab account to view).
Any workarounds for the extension that don't require a web server? Or other ideas to distribute my package to non-programmers so that they can use it?
Thanks!
I was in a similar situation, and I solved it in a slightly more elegant way than trying to play with web plugins:
In order to make the functions of my package accessible to non-programmers, I built a very simple GUI using guide in matlab, which allowed users to open data files, choose processing parameters, run the analysis, and export the results. Guide is very simple to use, and there are some good tutorials online. Then in terms of distributing it, I packaged all the necessary matlab files into a single folder, and then wrote a bash script (linux/mac) that would copy the files into a sensible directory, make a shortcut in /usr/bin/ (so that the GUI could be opened directly from the command line by running scatter_analysis without invoking any other display from matlab), and finally make a double-clickable shortcut on the desktop. The only prerequisite is that the user has matlab installed already.
I presume you're using windows, which I know nothing about, but I think it's likely that you can come up with a similar solution on the windows platform with far less effort than wrestling with web plugins? Unfortunately I cannot share my code - I'm in the process of selling it and any disclosure would violate the terms of the sale.

Categories

Resources