How to distribute a Java desktop application? - java

What is the alternative to distributing Java?
I don't want to add JRE in my extracted files.
I don't want to give away my .jar file to the user.
The end user just install and use application.
Which database to use so that the user don't need to configure like SQL Server.
How to decrease execution time of my application? It takes more time to execute.
Edit
It is an application without a database.
There should be a setup file which installs in Program Files and shortcut on the desktop and some registry entry to start it with start up application.

You can deliver Java desktop apps as Applets and (more recently) Java Web Start apps. Using these technologies means that users don't need to manually handle files.
As for RDBMS, there is a pure Java RDBMS going by the names JavaDB and Derby which might meet your needs.
There are many ways to improve the execution time of a program, it depends on what you've coded and what it does, for a start. I think you'll need to ask a specific question on that to get a useful answer.

Java Web Start works well as a distribution mechanism. Host the .jar on your site and your clients can download (provided they have a JRE). It'll select the appropriate JRE to use and allow you to update the application at your end with automatic downloads.
If you want a database, check out JavaDB. It's pure Java and comes as standard with Java 6. Your application can check for an existing db on start-up, and initialise/configure if not present. That will then remain for future invocations.

Related

Swing app installation [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I've made Java Swing application using hibernate (it automatically creates tables etc. when it is run). I need to make some installation version to my application, is it enough to just upload my jar file? What should I do when I want to publish my application? Just prepare link to jar and some readme which contains info that for example:
install newest version of java ( http://www.java.com/download )
make msyql database user 'user' with password 'password'
create database "application".
run application.jar
Edit
I want to simulate process of selling my application to some company. For example my application is hmm to manage some store, u can put there some notes, bills etc. This application works on some database, which ll be placed somewhere in this store, I don't want to make this application accessible from internet. So how should i install it? Readme file example was kinda bad, now we can assume that i need to go there and install for them database and configure it. So at the moment I need only to make possibility for company to install my software without me help, in cases for example hiring 100 new people.
If you want your app been redistributable. I'd use Java web start. Read the tutorial
Java Web Start software provides Java developers and users with many deployment advantages:
With Java Web Start software, you can place a single Java application
on a web server for deployment to a wide variety of platforms,
including Windows, Linux, and Solaris. Java Web Start software
supports multiple, simultaneous versions of the Java platform. An
application can request a specific version of the Java Runtime
Environment (JRE) software without conflicting with the needs of other
applications. Users can create a desktop shortcut to launch a Java Web
Start application outside a browser. Java Web Start software takes
advantage of the inherent security of the Java platform. By default,
applications have restricted access to local disk and network
resources. Applications launched with Java Web Start software are
cached locally for improved performance. Updates to a Java Web Start
application are automatically downloaded when the application is run
standalone from the user's desktop.
See also stackoverflow's info page Java web start info
In addition to the fine answer of #nachokk, I'll expand on points 1-3.
The best way to deploy a JWS app. or applet is to use the Deployment Toolkit Script.
(& 3.) Look to using the ExtensionInstallerService. That is what you'd used to install/configure the DB itself. Here is a demo. of the service.
You can create an installer with IzPack.
It can also be combined with Launch4J to download the JRE.

Hosting of a Jar file

I have a jar file which contains two Java classes. Using the javamail API I have developed these classes to read and edit my mail, then send to another mail id.
I am able to execute this through my standalone system via Eclipse. Now I want to host this jar file somewhere remotely so that it would fetch the data in real time and execute the job regularly. I have contacted couple of hosting sites and they are saying that they require a war file instead.
Does anyone have any suggestions to this problem?
To give you another point of view and to be constructive, I would go with embedding your jar into a war application and you get some things for free, the most important I think is that you gain a managed application lifecycle so with a standard web application context listener you can start and stop your program in a managed way. Besides you have more hosting options and it is less work.
Good luck with that.
As I don't know of any services specifically for plain execution of executables, your best bet is probably getting a cheap VPS. With some searching you can probably find one that would work for around $5 USD/month. For a single simple app you'd only need around 128MB of memory.
Pick one up, install Java (whatever Linux distro you get probably has OpenJDK in the repositories), copy your files over, and set up a cron job to run the executable at a set interval.
For easier administration, install something like webmin and use that to configure the cron job. The command would likely just be java -jar /path/to/my/App.jar, and you can use the web interface to configure the intervals for the command to be executed.
For an app like this, I would avoid anything related to a war file. You aren't making an application with a web interface (like a PHP app or some such) so it really wouldn't be appropriate. You would have to write some extra code to make it compatible with a container like Tomcat, and on top of that the memory requirements for running the application server would be a lot higher.

java application updator

I have a java application which is used many computers in my office network. This is a java swing application, and when there is an update most of the time I have to update each computer. Currently there is a mechanism to update these applications automatically but it seems like it is not working properly, that is I have a simple table in the database which hold the released versions number and when the application starting it checks its' versions against the database. If it is not tally then it downloads the whole application from the FTP server which we have installed in our network.
Recently thought to create a server to do this task. But, I don't know whether it is a good practice to do.
My idea is, there is a server which can get the md5 hashes of each file in the FTP server and send that hash list and file list to its' clients. When the clients (my swing application) get this lists it compares those hashes against its' files and if there is a mismatch client can download that file from the FTP server.
Please tell me that is this a good method to do for updating a java application?
You should use Java Webstart.
It's designed for exactly this scenario: automatic downloading and update of an application from the internet and/or intranet.
It even does clever stuff like application versioning and ensuring that new files only get downloaded when they are needed through intelligent caching.
Another option:
Since this is in an internal network. If you don't want to use webstart (best option).
Create a small front end application that use a URLClass loader and always load it on the fly. Since this is an internal network unless the application is huge. It should take less then a couple of seconds to launch.

Creating an installer for Java program with database

Recently I made an application in using Swing, AWT and JDBC that manages some database. I used PostgreSQL as the backend with JDBC drivers to connect to the database. What I want to do is create a setup/installer program so that the application can be installed and used on any pc. My problem is I dont know how to integrate the database along?
Any help would be appreciated.
Take a lesson from most commercial applications that have a database component. Usually they require that the database be installed/configured beforehand and provide db scripts for their supported vendors. There are a lot of reasons for this. Most of these are related to the fact that organization's like to manage their own databases. This is often because they have company restrictions regarding security, maintenance, etc. Also a single database process may be shared between many different programs(if you install two instances of your application do you want to have to two installations of the database?).
Most folks(especially network admins) wouldn't want an application that ran around installing rogue DMBS's on their machine.
I wouldn't spend a ton of time attempting to install the database during your install process. Why re-invent the wheel when the vendor has already created an installation process for you? Instead install the database ahead of time and focus your installer instead on running the necessary scripts such that your application can connect to it on the first start up. What it does means is having your installer have the necessary drivers, connection information, and credentials to communicate with the database to get it initialized. After the DB is initialized then you can have additional routines that configure your application install such that it points to the database you initialized during the install. Taking this approach will not only be easier, but it will allow your application to do more interesting things like connect to remote databases or skip database initialization all together and connect to an existing database.
Writing an installer that also manages DB installation is a project in and of itself. The big question is do you need to install PostgreSQL from scratch or will you tell the user to install it themselves first?
I have attempted to do something similar and what I eventually did was build an installer with NSIS that includes Postgres and a JRE in the install bundle along with my program. The installer copies everything to the user's install location and creates all the required config files.
The biggest issue I had was that I had a number of config options to present to the user that would have taken a lot of programming in NSIS. So, I modified the ANT build scripts I already had written to build the project. What NSIS does then is copy the JRE to a temp location and start a Java installer GUI I wrote instead that gathers up all the config info and launches ANT in the background.
If you don't have much to configure or what you need to configure doesn't have many options, then you can probably do everything in NSIS directly. But, keep in mind that you need to be security conscious too. How are you creating a new user to run Postgres? What about directory permissions for you install? Who can start and stop the DB, who can read the db files, etc?
Maybe you may try a pure java database, like hsql, or h2, or derby....

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.

Categories

Resources