1

I've been developing a Java Web Project in IntelliJ IDEA - it consists of a few Java classes for logic, a few JSP files for the web-based UI, and uses a MySQL database - all hosted on my own computer (MySQL server for the database, and Apache Tomcat 9 for the web app).

How would I export this project, including the database, so I can set up a dedicated machine (say a desktop running Ubuntu Server or Debian, or even a Raspberry Pi, perhaps) to run it?

I've done some research on this, and what I've found is that I need to export a WAR file, but I can't seem to find that option in IntelliJ - all the guides I found were focused on Eclipse. I also have no idea what to do about the database.

  • 1
    for IntelliJ .war file see this question: https://stackoverflow.com/questions/38562829/where-is-the-war-file-built-in-intellij-idea-located and for MySQL have a look in this question: https://stackoverflow.com/questions/13566735/how-to-export-mysql-schema-with-data – DevDio Sep 19 '17 at 08:54

2 Answers2

1

To setup dedicated machine for your application, you need to install web server(ex. Tomcat) and MySQL server on a machine.

Make sure that, when you are creating database connection in your WEB application, the MySQL server details should not be hardcoded. I would suggest you to use properties file to store Database details and use them for database connections. Ex.database.properties

mks.dynamicPool.config=\
url=jdbc:jtds:sqlserver://[yourmachinehost]:[SQL Server port]/[yourdatabase name];useCursors=true,\
driver=mks.frame.sql.jdbc.mssql.Driver,\
initialCapacity=5,\
maxCapacity=100,\
testTable=VersionIdentity
mks.dbUser=user1
mks.dbPassword=user1
  1. To create war file of you application follow the steps :

    1. Click on Edit Configurations.
    2. Click on Deployment and add your artifact.
    3. Apply these changes.
    4. You can see a Build Artifacts under Build.
    5. Click on Build Artifacts and it will create a war/jar to the respective folder.
  2. To deploy your application into tomcat server,

    • Copy/Extract your war file into [TomcatInstallDir]/webapps
  3. To import and export your database:

    I hope you have set MYSQL Server into your path.(if not then set using command: set path=c:\wamp\bin\mysql\mysql5.1.36\bin)

    i. To export database, following command can be used:

    mysqldump -u YourUser -p YourDatabaseName > dumpfilename.sql
    
    Note: This command should prompt you for password and with correct password it would export the database.
    

    ii. To restore/import above exported database use following command:

    mysql -u YourUser -p YourDatabaseName < dumpfilename.sql
    
  4. Update your database.properties file with your new Database details and start the tomcat server.

Kishor Jadhav
  • 196
  • 2
  • 16
0

Install on your dedicated server MySQL and Tomcat. Import your database into sql script and export it into dedicated server.

After that use some build automation tools, maven or gradle for example to build war package and deploy it (copy to ../tomcat/webapp directory)

Do you use some web-based framework?

dubace
  • 1,601
  • 1
  • 19
  • 27
  • I am not using any special frameworks - all of my front-end is some (very messily coded, I might add) JSP files, and the rest is just Java classes, and a couple of external libraries (such as the MySQL connector and JavaMail). – Neil Banerjee Sep 19 '17 at 09:24
  • then just copy all project files you have into ../tomcat/webapps/firstwebapp/* – dubace Sep 19 '17 at 10:01