Call Java file using System () in c

I am trying to run a java file that sits on my web server with c code. When I load the web page, the perl script calls the c file, which then calls the java file.

I have a call configured as in my c file:

System(java -cp <path> MyClass); 

But this call to System () returns 256 - (file not found, I think).

I also tried:

 System(cd /<path> && java MyClass); 

And get the same results.

If I run the same command from the terminal via ssh, it works fine, it's just when I try to run the code from my browser so that it gives this error.

Any ideas if my syntax is incorrect? Or am I doing something else wrong? Does this have anything to do with the java perl> c> chain that I have to use?

EDIT It looks like c runtime was not looking at $ PATH. I added the absolute path to java.exe and it will work! Wooo

TL; DR

decision:

 System("/opt/jdk1.6.0_43/bin/java -cp <path> MyClass"); 
+4
source share

All Articles