tags:

views:

124

answers:

4

I have made a java application that stores data from a .csv file to a MySql database. Now my client want it to upload this application to his web space (web space he has taken for his website) so that he can run that program on that server.

I have used FileZilla software to upload the program to his web hosting but now I don't know how to run that program on his server.

To run it on localsystem, it needs to open a command-prompt window to run it.

Is there any specific feature that the web-hosting must support to run that java program?

As it stores data from a file (.csv file) to a MySql database, then would it better to deploy that program on the server on which the database is being hosted instead of the server on which the website is being hosted?

+1  A: 

Your application is most likely a console application and not a web based one.

Your client will need to SSH to the server and do something like:

java com.foobar.FooBar

or:

java -jar FooBar.jar
cherouvim
yeah I know the command but where to give that command... Could you please explain about SSH to the server?
Yatendra Goel
You're gonna have to login to the remote server to run your program.
Zaki
http://en.wikipedia.org/wiki/Secure_Shell
cherouvim
+1 .... for providing a link to SSH
Yatendra Goel
+2  A: 

Having "web space" doesn't necessarily mean he has sufficient access to the server to run arbitrary programs (or a MySql database).

You could potentially rewrite the app as a web application, but that may well not be a good fit.

The first thing to check is whether he can log in to run programs from a console of some description. If he can, that's fine - and the way to go. If he can't, you'll need to think about why he really wants it to be on his web server, and whether it makes sense to run the app there - or whether it would be better to do it elsewhere.

Jon Skeet
+1 ... I explain you the scenario... He has hosted his mysql database on a server. Now I have made a java program that fills the database from a .csv file.. The program and the .csv file are at the same place... Now upto my thinking, the program should be run on the same server on which the database reside so that the program can store the data quickly in comparision to making a connection with a remote database... what would be the best approach according to you... access rights is not a problem because if he hasn't sufficient access rights right now, then he can upgrade or change his hosting
Yatendra Goel
@Yatendra: Then that's what you should do: make sure he's got hosting which supports remote access (either Windows or Unix) and which allows him to run Java apps directly from a command line. Many web hosting companies may not support this, particularly the very low-end ones - but there are those that do, too. Once you've got a hosting environment which allows you remote command-line access, you'll be able to run the app as normal.
Jon Skeet
+1  A: 

Indeed, saying "web-application", we usually mean a special application, programmed to run on the web-server all the time, just waiting for requests from user to process.

In your case, you have a console-based application.

Depending on the configuration of the server, no of these applications could be run on your client web-hosting, any of them or both.

Since, usually web-hosting is provided by hosting company, they may have configurations ready for running your applications, may have it turnable on/off or even take money for this.

In case of internal company server, you need to ask your customer and its IT-stuff to configure this.

Finally, you'll need to ask: 1. Does server support SSH? - it's simply a remote console. Usually it's running at port 22 and you many check it with command "telnet yourserver 22" (windows and linux) - if it doesn't reject your connect - means SSH is configured. 2. Does your server have java installed and if it is available for your account via SSH connection?

  1. Only if your customer really mean web-application instead of console based application you need to ask if server has web-application server for Java - usually, it's something like Apache Tomcat, Jetty, JBoss, Weblogic, etc. But this way will require application modification in order to run it in web-server.

If you will decide to use console-application and not "upgrade" it to web-application, you really may run it at the host your database is running (again, you'll need SSH). You'll save time on remote database access operations - theoretically, your program will work faster.

+1 ........... ............
Yatendra Goel
When I tried to issue a telnet command told by you above, I received the following text... "SSH-2.0-OpenSSH_5.1"....... I think that it supports SSH... how can I find that it has java installed and it is available via SSH connection...
Yatendra Goel
First you need to get SSH login/password from your client. Then, after you connect, you'll get the same command line like you have with your own desktop. Trying to run your program like you always do ( "java -jar program.jar" I believe) will give you an answer if java is available. If not - again, ask your customer (expecting he will forward such question to hoster) if it is possible to install java there.
A: 

If your webhost has java available you could try to execute it from a php cronjob without the need for ssh:

<?php system('java -jar /path/to/your/program.jar'); ?>

Cron jobs are easily done from cpanel.(P.S. the above is the code for the php file it is not what you put in the cron page, you put the php -f /path/to/php/file.php in the cron page)

DCC