|
From: <php...@li...> - 2006-06-12 10:25:47
|
for example
[code]
package jl;
public class phptest{
/**
* A sample of a class that can work with PHP
* NB: The whole class must be public to work,
* and of course the methods you wish to call
* directly.
*
* Also note that from PHP the main method
* will not be called
*/
public String foo;
/**
* Takes a string and returns the result
* or a msg saying your string was empty
*/
public String test(String str) {
if(str.equals("")) {
str = "Your string was empty. ";
}
return str;
}
/**
* whatisfoo() simply returns the value of the variable foo.
*/
public String whatisfoo() {
return "foo is " + foo;
}
/**
* This is called if phptest is run from the command line with
* something like
* java phptest
* or
* java phptest hello there
*/
public static void main(String args[]) {
phptest p = new phptest();
if(args.length == 0) {
String arg = "";
System.out.println(p.test(arg));
}else{
for (int i=0; i < args.length; i++) {
String arg = args[i];
System.out.println(p.test(arg));
}
}
}
}
[/code]
if i write "java_require("c:/phptest.jar"); $tf =new
Java("jl/phptest");",,,it shows error.
how can i write it?
|
|
From: <php...@li...> - 2006-06-12 14:44:53
|
Hi,
php...@li... wrote:
> ...
> if i write "java_require("c:/phptest.jar"); $tf =new
> Java("jl/phptest");",,,it shows error.
>
> how can i write it?
I think the syntax is $tf =new Java("jl.phptest"); - dot instead of slash.
Cheers,
Pat
--
------------------------------------------------------------------------
Pat Patterson <mailto:pat...@su...>
Federation Architect
Superpatterns <http://blogs.sun.com/roller/page/superpat> blog, Planet
Identity <http://planetidentity.org>
Identity Management Products <http://www.sun.com/identity>
/Sun Microsystems, Inc. <http://www.sun.com/>/
------------------------------------------------------------------------
|
|
From: <php...@li...> - 2006-06-12 18:41:59
|
Hi,
> package jl;
> public class phptest{ ...
> public String test(String str) { ...
> if i write "java_require("c:/phptest.jar"); $tf =new
> Java("jl/phptest");",,,it shows error.
>
> how can i write it?
In PHP/Java Bridge version 3.0.8:
jar tvf c:/phptest.jar should display:
jl/phptest
META-INF/MANIFEST.MF
The PHP code may look like:
java_require("c:/phptest.jar");
$tf = new Java("jl.phptest");
$tf->test("hello");
In PHP/Java Bridge 3.1.0 you can convert the java
library into a PHP class and require it:
convert your java library /libraries to PHP code:
java -jar JavaBridge.jar --convert c:/php5/pear
c:/phptest.jar
The above command creates the PHP class jl_phptest in
c:/php5/pear/phptest/:
<?php
/* ini_set("include_path", "c:/php5/pear"); */
require_once("phptest/jl_phptest.php");
$tf = new jl_phptest();
$result = $tf->test("hello");
echo "$result";
?>
Regards,
Jost Boekemeier
__________________________________________________
Do You Yahoo!?
Sie sind Spam leid? Yahoo! Mail verfügt über einen herausragenden Schutz gegen Massenmails.
http://mail.yahoo.com
|
|
From: <php...@li...> - 2006-06-13 07:44:19
|
> > "In PHP/Java Bridge version 3.0.8 > > jar tvf c:/phptest.jar should display: > > jl/phptest > > META-INF/MANIFEST.MF > > " > i jar tvf c:/phptest.jar not find jl/phptest , only list: META-INF/ META-INF/MANIFEST.MF TxtFileIndexer.class i m java newer. my compile procedure like this: javac phptest.java jar cvf phptest.jar phptest.class is it wrong? |
|
From: <php...@li...> - 2006-06-13 16:59:03
|
Hi,
java it requires that the Java package hierarchy must
match the Unix directory hierarchy. If you have a
class foo.bar.Baz.class, this class must be placed in
the directory foo/bar/ (on windows: foo\bar\).
BTW: The URLClassLoader goes even further by requiring
that a file url to a directory must end with a slash,
even on windows. For example on windows
loader = new URLClassLoader();
loader->addURLs(new URL[]{"file:c:\\directory\\")}
will fail but
loader = new URLClassLoader();
loader->addURLs(new URL[]{"file:c:\\directory/")}
will succeed.
> i m java newer. my compile procedure like this:
> javac phptest.java
> jar cvf phptest.jar phptest.class
mkdir jl
mv phptest.java jl
javac jl/phptest.java
jar cvf phptest.jar jl/*.class
on windows:
mkdir jl
copy phptest.java jl\phptest.java
javac jl\phptest.java
jar cvf phptest.jar jl\*.class
Regards,
Jost Boekemeier
__________________________________________________
Do You Yahoo!?
Sie sind Spam leid? Yahoo! Mail verfügt über einen herausragenden Schutz gegen Massenmails.
http://mail.yahoo.com
|
|
From: <php...@li...> - 2006-06-14 12:08:40
|
dGhrIHWjrGl0IHdvcmsgd2VsbKOso6x1IHIgZ29v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