2

I have this folder structure

C:\a\b.java
C:\a\b.class
C:\a\c.java
C:\a\c.class
C:\a\ftp.jar

From PHP, I used exec("java b"); This executed b.class file. That is fine. Now I should execute c.class file from PHP. In c.java, I have created an object for the class which is in ftp.jar. So I should set classpath for this. But I couldnt set classpath from PHP

But when I do it from cmd, all working fine. Please tell me how to set classpath from PHP?

user2314387
  • 265
  • 2
  • 4
  • 10
  • That's a Nice one. Review http://stackoverflow.com/questions/945962/java-problem-running-a-jar-file-in-command-line – Hanky Panky Apr 24 '13 at 07:34
  • actually i don't Know anything in `PhP` , but as a `java` , what happen if you add this `jar` file to `java` classpath?? – Alya'a Gamal Apr 24 '13 at 07:38

1 Answers1

0

This might work (provide explicit cp argument, I haven't tried though):

exec("java -cp  C:\a\d.jar c"); //if d.jar contains c.class

or

exec("java -cp  C:\a c"); //if d.jar doesn't contain c.class
harsh
  • 7,502
  • 3
  • 31
  • 32