-2

I have an E-commerce web site coded with PHP. I use a Java program with it, written in Eclipse, for things like encryption. The site, with the Java program, work well locally.

exec("java test 2>&1");

I hosted my website on Hostgator, but I don't know where to upload the Java program and how to link it to my PHP website. How can I do this?

2 Answers 2

1

You probably cannot.

It's rare and often very costly to buy hosting on a server that allows you to run regular applications on it too.

Amazon offers 1 year free hosting on AWS EC2 micro instance in which you have full access to a Linux or Windows server with very limited resources (probably not enough page views allowed for an E-Commerce site), but on such a server you can do it.

0

(Likely incomplete) list of issues to be sorted out:

  • You'll need a compatible version of Java installed on the host machine. Your host may not have it installed and likely will not be willing to install it for you.
  • Once you get a host machine with Java installed, you'll need proper permissions to access it. This is also unlikely, as your host does not want you using Java on their web-hosting-only package.
  • You'll then need to know the absolute path to the Java program that you uploaded, as it would be bad practice to use a path relative to PHP's context (ie, /home/user3924138/MyJavaProgram.jar

It sounds like what you want is a VPS (Virtual Private Server) where you have full shell access and can install Java and a webserver yourself and do what you are trying to do here.

3
  • @Xabster is it possible to host my java program with the Amazon offer and keep my php web site on hostgator and use the java program in my website ?
    – Ghaffe
    Aug 9, 2014 at 2:11
  • Not without modification to both the Java and PHP program. You would have to expose an interface to your Java application somehow for your PHP program to call -- perhaps an HTTP endpoint, Java RPC, or something else. Either way, how complex is your Java program? It would likely just be easier to rewrite the Java stuff in PHP if it is not very complex. Also, why did you cite Xabster's answer but reply to mine? Aug 9, 2014 at 4:08
  • "To also notify a previous commenter, mention their user name: @peter will both work" I wanted his point of view too
    – Ghaffe
    Aug 9, 2014 at 10:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.