I need to export my project
Im using Eclipse and MYSQL. My project is working fine in IDE and my database is already connected.
The problem is that I don't know how/where should i start?
I read things about like making a file contains manifest.mf, exporting project through runnable jar, maven etc. As a result of reading and searching too much of "how to export it", those things made me more confuse and i don't know what should i do anymore.
What i want to do is for someone on other computer can access my application without opening an ide or sql (is it possible?)
So can someone clarify and give me guide how to export your whole project + database in the most simplest way if possible, because im new to this thing.
Use an embedded database and setup the database in the start of your application.
The main contenders in the java space are HSQLDB, H2 and Apache Derby.
If this is not required by your application it will be an extra hurdle, then evaluate the trade off between changing the application to use an embedded database versus setting up a server to be accessed from the other computer.
Related
So, i've just finished a small javafX application, with database and stuff... I used Netbeans and SQl developer, now i want to export my project so i can use it anywhere i want; any computer, So, i've tried some programs like Launch4j or something... but the main problem is, even if i make the .exe file, what's gonna happen with the database? it's located in my PC, so if somebody try to use my application, he can't access to the database, so the application won't work...
In other words...What is the solution that i can use to like "Combine" the database with the application, if it is possible? or create the .exe file with the database... I hope that my problem is clear, and thank you for your answers .
as per my understanding you can do two things.
You can deploy or host your database to any online server and create some web services to fetch and insert data to your application.
You can create one startup class to create database but here you need to use lite version of database like sql-lite.
if you need more information about sql lite then click here
So I've created a java desktop application using Swing. It stores data entered into the application in a MySQL database (localhost). Now how would someone else be able to use the application ? Would they require a MySQL database as well ? What are the best practices for doing this. I do eventually hope to submit the entire project folder to github.
I guess I would have to ask first whether this program is a demo or classroom project or if it's a real application, because the answer would be different.
For a demo project, it would be fine to post your code to github, and also dump the database to a .sql file and commit that as well. MySQL ships with a handy tool called mysqldump that will do just that - export the entire contents of your database. Then a person can clone your github repo, install MySQL locally, and run your sql script to get a copy of your database. Once they follow those steps, they should be able to run a copy of your swing app on their machine just like you can. One caveat here though is it's best practice to avoid putting very large files (especially binary files) in git. I'm not sure what you need, but if you can put a small sql file out there that's definitely preferred.
That's a segue into the other answer which is hosting your MySQL database somewhere. For a real application, making copies just won't do. Then what you need to do is host your database centrally using a service like this one and allow your users to connect to it. You can still use mysqldump to get your database out there on the web after creating it on localhost. If you go this route though, you'll definitely want to avoid putting your database connection strings on github. Again, this scenario is really only useful if your app is intended to be used for real - don't bother with hosting if you don't need it.
Hope this helps!
Firstly, you should install mysql with a public ip, then alter the connection to mysql with the ip,the example follows below
String url = "jdbc:mysql://ip:3306/db";
Connection conn = DriverManager.getConnection(url, user, password);
if you want to run java program like exe file, package the java program to a jar file with jre
I guess I'm just not "getting it". If I don't have SQLite already installed on my computer, and I want to write a Java app that uses an embedded database, and I download/import the SQLiteJDBC JAR into my project, is that all I need? Or, do I need to first install SQLite before and create a database file for my SQLiteJDBC code to connect to and run queries from?
If that's the case, and its not sufficient to just download/import SQLiteJDBC, then doesn't that mean that I'll have to make sure SQLite is installed on every system that I want to run my Java app on? And doesn't that defeat the purpose of a portable/embedded database?
Basically, I'm getting hung up on the SQLiteJDBC tutorials because:
They don't tell you how HelloWorld.sqlite gets created (does SQLiteJDBC create it for you, do you have to create it in SQLite first from the command prompt, etc.); and
They never clarify whether SQLiteJDBC is dependent on SQLite for the API calls to work
Any help here is greatly appreciated!
You have to put the SQLLite JAR in the CLASSPATH of your app. There's no "install" beyond that.
Maybe this tutorial can help you.
Here's another that shows how to create a database and tables.
I have finished writing a Java Desktop application with a mySQL database. I want to make the application run outside netbeans and let it be installed on other computers. I know about building the project and creating the runnable jar file, however this requires me to export the database itself to the other computer I want the application to run on.
My question is two parts:
1)Is there a way I can create a setup file that also installs the database and the application together?
2)Also my database path is hard coded, does that mean I have to change the code every time I install my application for someone, what is the better way to do that?
Thanks
Yes. You can use some setup builder, like InnoSetup, for example. Personally, however, I like giving my customers a zip file, which they extract wherever they like. The executable jar should be able to handle everything by itself (I like it where there is no need to install the software, just unpack and run).
If it is hardcoded, then yes (but, what do you mean by hardcoded? path to file? ip address?). You should use properties or configuration files for paths and other external things your software depends on. The software should read from those files. Upon startup check for presence of such file(s) - if missing, the user should be shown a window in which the config can be entered.
As for deploying MySQL with your code - consider using a server for that, so that your users are not forced to install MySQL, instead they connect to it over the net. If you need the database only for storing data locally, why not using SQLite or a similar, file-based db engine?
The above answers are just suggestions and more-less reflect the way I am thinking. I would be happy to hear from someone with more experience. Nonetheless, I hope the answers help a little :)
I agree with Sorrow.
If I have to use MySQL, it is normally over the net since I don't want to allow my clients pass through the hazzles of installing MySQL themselves. If however you am stuck with using MySQL locally, investigate MySQL unattended installations + NSIS Installer.
If you can use any db you want, I just use javadb/derby. It comes bundled with most Java installations these days and if not all you need is to add a jar file to you application.
As per 'hardcoding' paths, I really don't understand what you mean. You really don't have 'paths' as it were, I am assuming what you mean is connection string. You don't have to hardcode your connection string, just put some parameters in a properties file and construct your connection string from them.
1) Is there a way I can create a setup file that also installs the database and the application together?
See my answer to Java based Standalone application.
2) Also my database path is hard coded, does that mean I have to change the code every time I install my application for someone, what is the better way to do that?
Have the DB installer pop a JFileChooser to ask the user where they want to install the DB. Store that path using the JNLP API PersistenceService. Here is my demo. of the PersistenceService.
I have some database applications (CRUD), and I want to create a desktop application with some buttons such that clicking on them lead to run those applications. How could I do this?
I have tried adding the CRUD projects as class path for the desktop application, but it didn't work out, with an exception in CRUD's lines indicating a class can not be found or something.
I'm using NetBeans and those database applications were created automatically by NetBeans from my MySQL server.
OK, I found a solution on this although this is not what I wanted, but it's working.
First, I built all the database applications as JAR files.
Next, in the event handler of my buttons I added this line of code in order to execute the JAR file:
Runtime.getRuntime().exec("java.exe -jar CRUDapp1.jar");
So every time I click the button the application runs.
Although this is working fine for me, but it seems not to be the right solution. I rather prefer solutions like adding classpaths or similar, but because of some conflict in the class name, that I don't know where they come from, classpaths didn't work.