I am just a budding developer in Java and now I need to build a stand alone application (not a web app but a client app which needs to run on the desktop) which needs to interact with a database. Could someone point me as to which technology/framework is best suited which would help me achieve this?
Is there a framework in Java which can help one to interface with both a simple database (such as MySQL) and help you create really good GUI which can be later converted to a Windows .exe executable?
-
You should realize that Java is a word and not an acronym, thus it should be written as "Java" and not "JAVA".Steve Kuo– Steve Kuo2012年08月08日 18:23:24 +00:00Commented Aug 8, 2012 at 18:23
6 Answers 6
A Java Program can never be converted to an .exe. The output usually will be a jar File
which can be run on any OS as long as you have JDK on the system.
You can use Swingin JAVA for creating good GUI and can use MySql library for JAVA to easily connect to MySQL.
Comments
Complementing to Byter's answer:
you will use two libraries/frameworks. One for GUI the other one for database access. As an option for GUI there is also SWT.
For database access can simply use java's built in JDBC with mysqls jdbc driver.
Comments
I'd recommend that you layer your application properly and do things in stages.
You can get the database piece working without a UI. I'd advise you to do that first. Develop it, test the snot out of it, and put it aside.
You'll want a service layer between the UI and the database. It'll manage requests, validation, security, transactions, etc. Develop it, test the snot out of it, and put it aside.
Only when the rest of it is in place should you proceed with the UI.
Comments
You asked for frameworks and Tools:
- First of all I would use Swing, since it is the standard and very well supported among all platforms out of the box
- At the moment I think I would go with the Better Swing Application Framework (BSAF). It is lightweight and very good extendable
- For designing the UI I would recommend using Eclipse and the Window Builder plugin. It does a decent job with 2-way editing (means you don't have blocked regions in your code and it is also able to interpret existing GUIs)
- Another way would be drawing your UI by hand and implement it with custom layout managers like JGoodies Forms or MigLayout
- For accessing the DB I would also recommend an ORM mapper like EclipseLink (never worked with it) or Hibernate (use and like it a lot).
- I would always draw a separation layer between the UI and the database by adding a service layer. Why? It greatly increases maintainability! This can be very well accomplished with either the Spring Framework, which can run with your ORM mapper and everything on a client machine, or with Enterprise Java Beans, if you plan to use an application server to which the client will connect.
- For delivering your application you could use a common installer tool like the Nullsoft installer which includes a JRE and then wrap the application with another tool like Launch4J (although I have never tried this one).
If you are new to Java or object oriented programming in general, please read Effective Java (genereally for Java) and Martin Fowlers descriptions of several presentation patterns - here I like the passive view most.
It is really a lot to learn, but if you want to do it "right", then I think there is no way around it.
Comments
If you are very new to Java I recommend an easy to use IDE for start. I would go with JDeveloper is the official oracle IDE and has pretty much everything you need to develop a desktop or web application even with a visual designer. It is free, I think it requires you to sign up to the oracle site but it's worth it.
Here's a tutorial on how to build a small visual java application with JDeveloper and swing: http://docs.oracle.com/cd/E18941_01/tutorials/jdtut_11r2_2/jdtut_11r2_2.html
As for the technologies for database, the best would be if you could use a ORM. I recommend JPA with EclipseLink wich comes already inside the JDeveloper IDE, here's a tutorial on how to do that: http://st-curriculum.oracle.com/obe/jdev/obe11jdev/ps1/ejb/ejb.html
But if you don't want to get in to the ORM learning (you really should eventually) then just use plain JDBC (there are tons of tutorials on how to do this in the web)
An alternative to JDeveloper is Netbeans which is also an official oracle tool as is much lighter.
Comments
Asking "Is there a framework in Java which can help one interface with both a simple database" will get you a ton of answers. The simplest response is "Look at JDBC", which pretty much all other frameworks will leverage to communicate with a database.
I'm not sure I'd recommend one framework that performs both the database connectivity and GUI stuff. Keep them decoupled. Like Byter above, I find that Swing works well.
If what you're asking about is reporting functionality, I keep hearing about Jasper reports.