Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP/Java Bridge UnsupportedClassVersionError
    text
    copied!<p>I need to run some java code on php so I found this </p> <pre><code>http://php-java-bridge.sourceforge.net/pjb/index.php </code></pre> <p>so I downloaded tomcat and put the JavaBridge.war in the webapps directory and I got the examples working (It took me a while to figure this out)</p> <p>I can even load built-in java stuff <code>Java("java.lang.System")</code> and run the example jars with my own PHP code. </p> <p>What I couldn't do was make my own jar and run it I tried a variety of different compilers (Eclipse,Netbeans,command-line) but this didn't help.</p> <p>I'm trying to do something like this <a href="http://www.developer.com/java/other/php-with-java-using-php-java-bridge-tutorial.html" rel="nofollow noreferrer">http://www.developer.com/java/other/php-with-java-using-php-java-bridge-tutorial.html</a></p> <p>Here is my java code:</p> <pre><code>package m1sk; /** * * @author M1sk */ public class Hello implements java.io.Serializable{ String hi() {return "This is my hello message";} String hello(String name) {return "Hello" + name;} } </code></pre> <p>php code:</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8"&gt; &lt;title&gt;&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;?php require_once ("java/Java.inc"); // $t1 = new Java("java.lang.System"); //echo $t1-&gt;getProperties(); //this works $world = new java("m1sk.Hello"); // echo $world-&gt;hi(); echo "Hello Working Thingy\n\n"; ?&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>i put the jar in ...\tomcat\webapps\JavaBridge\WEB-INF\lib and the php file in ...\tomcat\webapps\JavaBridge</p> <p>and i get the following error when i test <code>http://localhost:8080/JavaBridge/mytest.php</code>:</p> <pre><code>javax.servlet.ServletException: java.lang.RuntimeException: PHP Fatal error: Uncaught [[o:Exception]:"java.lang.Exception: CreateInstance failed: new m1sk.Hello. Cause: java.lang.UnsupportedClassVersionError: Bad version number in .class file (unable to load class m1sk.Hello) VM: 1.5.0_20@http://java.sun.com/" at: #-13 org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:1854) #-12 org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:890) #-11 org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1354) #-10 org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1233) #-9 java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319) #-8 java.lang.Class.forName0(Native Method) #-7 java.lang.Class.forName(Class.java:242) #-6 php.java.bridge.Util.classForName(Util.java:1518) #-5 php.java.bridge.JavaBridge.CreateObject(JavaBridge.java:445) #-4 php.java.bridge.Request.handleRequest(Request.java:458) #-3 php.java.bridge.Request.handleRequests(Request.java:500) #-2 php.java.bridge.http.C in C:\xampp\tomcat\webapps\JavaBridge\java\Java.inc on line 195 php.java.servlet.fastcgi.FastCGIServlet.handle(FastCGIServlet.java:499) php.java.servlet.fastcgi.FastCGIServlet.doGet(FastCGIServlet.java:521) javax.servlet.http.HttpServlet.service(HttpServlet.java:617) javax.servlet.http.HttpServlet.service(HttpServlet.java:717) php.java.servlet.PhpCGIFilter.doFilter(PhpCGIFilter.java:126) </code></pre> <p>I search the stack found this for my error: <a href="https://stackoverflow.com/questions/6066103/what-is-the-reason-for-unsupportedclassversionerror">What is the reason for UnsupportedClassVersionError?</a></p> <pre><code>C:\Users\M1sk\Desktop&gt;java -version java version "1.7.0_04" Java(TM) SE Runtime Environment (build 1.7.0_04-b22) Java HotSpot(TM) 64-Bit Server VM (build 23.0-b21, mixed mode) C:\Users\M1sk\Desktop&gt;javac -version javac 1.6.0_25 </code></pre> <p>the version are different but this should still work so I don't believe this is my problem</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload