I am new in web development, please help about the uploading the java website on live server with mysql database.Please tell all the steps.
It you want to test your application on live server.
Try it with Jelastic, a free trial for 2-weeks which gives you better understanding on deploying and testing your java web application on live server.
Unrelated
If you are using JBoss Application Server 7, deploy your application over LAN network (deploy on 1 system and access from any other device)
Export your application in EAR or WAR from IDE
Just copy and paste you WAR/EAR file in deployment path like(D:\jboss-as-7.1.1.Final\standalone\deployments)
open cmd, change directory to bin folder of JBossAS7
Write command standalone.bat -b 0.0.0.0
Access your application like: http://192.168.1.9:8080/YourApplication
Obviously put your own PC's ip over here. Hoped helped. It gives you an Idea of hosting
To deploy java on live server
firstly convert your java project to war file. Then rename it to root.war.Now open the tomcat manager provided by hosting service provider.Browse the root.war file and deploy it.
Secondly,for mysql db... Create mydb.sql file.Now go to your cpanel and create the database .And after that add the username and pass to myconnection utility java program.Now in cpanel go to phpmyadmin ,Click on the db created and import the mydb.sql created.And now you have successfully deployed the java project.
Related
I'm new to deployment, I've jar file as a package how should I go ahead for deployment in my prod server?
My prod server is basically an EC2 machine running on AWS
Shall I just run java - jar "jar file"? is this the practiced way for prod servers?
Shall I package .jar file to ear/war and deploy in tomcat/jboss server?
Help appreciated!
Both of the approaches you described are valid.
For small web APIs that include their own application server (e.g. Spark, Javalin, Spring Boot) on Linux servers, I start a screen session and run java -jar. This allows me to exit the SSH session (disconnect from the server) without terminating the program.
For other Spring applications that don't include an application server, I package the code into a WAR and copy it to an application server's deployment directory. For Tomcat, that's webapps. The application server can then read the WAR and spin up a running instance (assuming hot-deploy is enabled).
Tomcat in particular also has a web page where you can upload your WAR file to deploy it.
If you would that the program is still held run after disconnecting from SSH or closing the terminal in Linux. You can use this command:
nohup java -jar file.jar &
This is basically up to your preference and usual standard at your place. We have services in Docker that basically have exec java -jar param param... at the end of entry-point.sh script. You can run whole Tomcat, etc.
If you're using Spring Boot (which is a good idea), then java -jar is perfectly fine - you can use embedded Tomcat and skip installing dedicated application server (or, to be precise, servlet container).
Second approach is preferred over first in Jboss servers as things can be easily done through console.
You can control the deployment of the application on the servers.
If say you don't want to deploy the jar on all the servers part of cluster ,that can be taken care.
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.
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
To create war file of you application follow the steps :
Click on Edit Configurations.
Click on Deployment and add your artifact.
Apply these changes.
You can see a Build Artifacts under Build.
Click on Build Artifacts and it will create a war/jar to the respective folder.
To deploy your application into tomcat server,
Copy/Extract your war file into [TomcatInstallDir]/webapps
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
Update your database.properties file with your new Database details and start the tomcat server.
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?
I have made a project and I made it online through Openshift.My project is still online on openshift URL http://easynote-sansari.rhcloud.com/ , but due to mistake is deleted from my local server.
I want to get back my project in my local server for further improvement. Please help me to get my project back from Openshift.
thanks in Advance.
Depending on how you uploaded your project to OpenShift Online, you have a couple of options for recovering your files.
SCP/SFTP : You can use a file transfer program that supports the SCP or SFTP protocols to download the files for your website, which should be located in your ~/app-root/repo directory.
Git : If you were using Git to add/push your files to your OpenShift online application, you can re-clone your application to your local machine using the rhc git-clone command.
Download an Archived Backup : You can use the rhc snapshot-save command to created an archived backup of your application, which will then be downloaded to your local machine. You can then decompress the archive and extract your files.
I have a website someone's developing for me on a VPS (Java, javascript, CSS, HTML) that I would like to run on my Macbook Pro.
He commits the source on Github, which I download with Sourcetree.
I have Tomcat 6 and MySQL running on the Macbook fine.
Can I bring the root folder, the mySQL db and an associated media folder over without creating a .war file to run it on tomcat on localhost by simply setting up the connections properly in datanucleus, or is it much more complicated than that?
Thanks in advance for your thoughts.
I know people who try to develop application directly in die Webapp Folder from Tomcat but that is not the right way.
At your place i'll do this:
clone the application locale on your mac
Use an IDE(eclipse/Netbeans/IntelliJ) to open the project
Build a local war file which you can deploy directly to your $CATALINA_HOME/webapp/
Do not forget the make all required mySQL settings (context.xml) and so on...
Yes, you can. But it is necessary to have compiled webapp.
Simply put root folder contents (your deployed application) to "/webapps/ROOT" and start tomcat by running script in "bin" folder.
Make sure that you properly configured database properties of your application.
If you have only sources - it is not such simple. You have to build war and deploy it. Or ask developer to include "target" directory in git repository and then copy "classes" folder to /webapps/ROOT/"
I am currently using the cloudfoundry eclipse plugin to deploy my JSP/Servlet web application. My application is now using a Db (Sqlite). However I am having problem deploying the sqlitejdbc.rar to cloudfoundry (all i do to update the application is right click on my application under VMware Cloud-foundry server and select update. But that doesn't seem to work and i get an exception saying that it cant find the rar file.
In my local system i simply paste the sqlitejdb.rar to the lib directory of Tomcat and when i run the webapp locally it works
If you place the sqlitejdbc.rar file into your lib directory (inside your WEB-INF directory) that should get deployed as part of your application into cloudfoundry and become accessible.
You can also try to deploy your app using vmc push to see what errors you get from vmc.
I also recommend looking at the log files on cloudfoundry.com