Java Desktop application - java

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.

Related

If I install a new library, will my application still be portable?

I am writing a macro scripting program in Java (JavaFX). I would like to add global keyboard listeners to interact with the program while it is not focused. I have heard of JNativeHook, and it looks useful. My question is, if I decide to use this library, will my code still be portable? Could I still distribute it to others without requiring them to install other things?
You can absolutely include native libraries in a portable app as long as your code can find the DLLs in question and you bundle them with your software. I personally use SIGAR in portable apps and it works fine as long as the relative path remains the same, depending on how you load your DLLs.
******EDIT******
That is of course if you remain within a Windows environment and you are indeed talking about DLL files. If you mean additional JAR files that do not require anything else than java code contained withing JAR files then yes your app will be fully portable, cross-platform too. That is what i love about Java, i once developed a large app on Windows and it ported to Ubuntu with no modifications whatsoever.
You can make your app portable if you don't need any special insulation for a different device uses different platform so in your case the library you asking for JNativeHook need some requirements mentioned here https://github.com/kwhat/jnativehook#software-and-hardware-requirements. You have to give instruction to your user to have these requirements based on the platform he/she works on.

How to deploy java app for Windows pc

I have studied Java Web Start and found it complex and clumsy for my purposes. In addition, my app needs to access the PC resources, which causes more hoops to be jumped through with Java Web Start. To add to the difficulties I need to access a 32-bit native library (libvlc) so I need to insure that my app runs under 32-bit Java. Is there an easy way to deploy my app without resorting to Java Web Start? Needless to say, I want everything to be contained in a single .exe file.
I would start by searching the Internet for keywords such as "java 2 exe" and "jar to exe", etc. Doing so yields many freely available software packages that convert Java programs into Windows executables, for example:
JexePack - http://www.duckware.com/jexepack/index.html
JarToExe - http://www.regexlab.com/en/jar2exe/
JSmooth - http://jsmooth.sourceforge.net/
And the list goes on. Perhaps one of them meets your needs?
I am answering my own question to help people understand how to do this, which has taken me some number of days to figure out.
My initial problem was that my app would run on some versions of Windows but on others it was having problems finding the libvlc native library. I finally figured out that my app must run with 32-bit Java in order to use the 32-bit native library. Thus, the problem then became how to insure that the user started my app with 32-bit Java.
I read about Jar2Exe (http://www.regexlab.com/en/jar2exe/) in another post and decided to check it out. It is a great little program that is very configurable so I figured that it must be able to handle my 32-bit Java problem. In fact, it does so without even needing to do any configuration. The resulting .exe file contains my app along with all the required jar files and starts up with the 32-bit Java. I am very pleased with this program and plan to buy a license, which is very cheap.
Hope this saves time for other people who are trying to solve a similar problem.

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).

Migrating Delphi App to Java or to Web App

We want to migrate UI rich application from delphi to java or Web Application.
Reason is that we want application to be portable on all Operating Systems.
Current Components and Modules of Application in Delphi :
In Delphi we are utilizing TWebBrowser component to display HTML content
We are playing mp3 that is extracted from FileStream on clicks in HTML.
All resources for HTML are retrieved from Embeded Database Firebird/Ms Access.
To sync some content we are doing HTTP post to PHP scripts to centralize the data on webserver.
Deployment:
- Application has to be deployed on CD and installed on Desktop computer on Mac OS, Linux, Windows.
I need your help how to approach this migration. Is better to go with Java UI or Web App that will be deployed with WAMP/XAMP and appropriate distributions on Linux and Mac's.
EDIT:
I have some specific requirements for audio functionality. Audio files are separate files distributed on CD or USB. Audio files are one solid file compiled from mp3's inside. Application will have to have ability to extract the mp3 based on offset and size of mp3 stored in index file and to play in real time... How this affects idea of Web App using this approach.
Why don't you give FreePascal a try? It uses the same language as Delphi, and can compile to a native application on Windows / Linux / Mac. Since you already have your app in Delphi, converting it shouldn't be too difficult.
Have a look at the freepascal website
If I had to deploy on a CD, I'd probably go with Adobe's AIR. It is really fulfilling the promise Java made 10 years ago in a reasonable way. It isn't perfect, but it does a pretty good job.
I've heard this internet thing is really taking off.
For all of the reasons that applications have gone online over the past 10 years, there really isn't much discussion to be had.
While Java is reliable, distributing and rolling out subsequent updates to those applications is heavy and time consuming.
I did Delphi development for over 9 years. I resisted the idea of distributing real applications over the web for quite some time. Today, I can't believe anyone would choose to continue in this way.
One nice thing, you can probably reuse some of your Delphi logic on the backend if you get creative. (I would only recommend this for the short term)
But, this answer doesn't really address your issue as you are saying that you must distribute it via CD.
The Java 6u10 release allows for distributing Java WebStart applications on media instead of from a Webserver, which might be exactly what you are looking for. You can also put the JRE installer for Windows on the CD too, if needed.
What exactly are your requirements crossplatformwise?
If most of the application is HTML-based, why not make it a full web application, using Ajax and Java?
I recommend NetBeans, and ICEFaces, which is a Java Server Faces implementation with Ajax support, including concurrent updates - if one user edits a record, all other users will see an update in their web page.
It is possible to package the whole application in a single jar file, including the servlet container (Jetty for example), so a simple java -jar myapp.jar will run the application.
NetBeans allows visual editing of the ICEFaces web pages, and even visual editing of the page relationships. The tutorials on NetBeans.org are excellent, and with tools like Maven, Hudson and others, code quality and development process can reach a very high level.
If you have some Delphi application using Datasnap : you can also re use your server made in Delphi with Datasnap in Delphi Prism and make Silverlight application.
And the same is true for DataAbstract

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