Search code examples
javaphpjarfusionchartsbatik

How to reference the path of jar files that are packaged in a WAR


Background: I'm building a dashboard using PHP and FusionCharts (for building a chart) for our website. One of the features of FusionCharts is to save the chart on the server but for that, the server should support Java (1.3 or above). The application will have php files and the batik library (set of jar files) to support the 'export to server' feature. This feature worked completely fine on localhost as I have both PHP and Java running on my machine. On the other side for the server, our hosting providers for the website were able to install Java on our PHP server and in order to run my application, they want us to upload WAR file. I did create a WAR file of the batik library and uploaded it to the server. It is located at www.domainname.com:9080/batik (9080 because it is using a different port for Java)

Problem: In one of the PHP files, there is a reference to one of the jar files located in the batik library. FusionCharts documentation suggested that I'd need to reference the jar file using absolute path of that jar file.

For localhost, I didn't create a WAR file [batik is just a directory] and the code looks like: define ('BATIK_PATH', 'C:\wamp\www\BatikSAMPLE_v3.3.1sr3_Eval\V3.3.1SR3\Resources\batik\batik-rasterizer.jar');

For the server, I had to create a WAR file for batik and I tried similar code as below for the file on the server: define ('BATIK_PATH', '/var/www/vhosts/domainname.com:9080/batik/batik-rasterizer.jar'); but I'm not sure if I can reference the jar file directly as above from a WAR file. It didn't work this way.

Overview of batik file hierarchy: batik (parent) has a sub-directory 'lib'(that consists of multiple jar files) and also a jar file 'batik-rasterizer.jar' on the root level that I'm trying to reference to.

I have no expertise in Java and I've not used jar and war files before. I wanted to make sure if the path that I gave in the script is a correct way to reference jar files that are packaged in a WAR file and also if I'm missing anything because of which the application is not running.

Thanks


Solution

  • Certainly, you would need Java to use the batik exporter. Your current setup says that you have deployed the batik files to tomcat server which is why you have uploaded the WAR file. Actually you don't have to do that.

    Simply upload the jar files to any location where your PHP code can access and define the BATIK_PATH. Let me know if this worked.