mercredi 11 janvier 2017

Run CGI Java Program

I want to run a java program with Apache HTTP Server. I'm struggling to show simple output in the browser.

In my cgi-bin folder I have CgiTest.java which looks like this:

#!"C:\Program Files\Java\jdk1.8.0_101\bin\java.exe"
public class CgiTest {
public static void main(String[] args) {
    String type = "Content-Type: text/html\n\n";
    String output = "<html>" +
            "<p>Hi there </p>" +
            "</html>";
    System.out.println(type);
    System.out.println(output);
}
}

The error I get is:

End of script output before headers: CgiTest.java
Error: Could not find or load main class C:.Apache24.cgi-bin.CgiTest.java\r: C:/Apache24/cgi-bin/CgiTest.java

How to run my java program? If I have to invoke it from some script how to do it?




Aucun commentaire:

Enregistrer un commentaire