473,799 Members | 2,727 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Calling Java Classes on Server

I have the Java JVM installes on my server.

I uncommented
extension=php_j ava.dll
in php.ini

I uncommented and proerpyl filled out the [java] section in php.ini:
[Java]
java.class.path ="C:\InstantRai ls\php\extensio ns\php_java.jar ;C:\JavaSources \MyStuff"
java.home = "C:\Program Files\Java\jdk1 .5.0_10;C:\Prog ram Files\Java\jre1 .5.0_10\lib"
java.library = "C:\Program Files\Java\jdk1 .5.0_10\jre\bin \server\jvm.dll "
java.library.pa th = "C:\InstantRail s\php\extension s\;C:\Program Files\Java\jdk1 .5.0_10\jre\lib "
I created a little php file to test it all out:
<?php
$system = new Java("java.lang .System");
echo 'Java version installed = ' . $system->getProperty('j ava.version') . "<br />";
echo 'Java vendor = ' . $system->getProperty('j ava.vendor') . "<br />";
echo 'Running on server = ' . $system->getProperty('o s.name') . "<br />";
$des = new java("DES","xra y");
echo $des . "<br />";
$x="hello";
echo $x . ' = ' . $des->encrypt($x);
?>

Which outputs as:

Java version installed = 1.5.0_10
Java vendor = Sun Microsystems Inc.
Running on server = Windows XP
Object
hello =

Note that I have a class file C:\JavaSources\ MyStuff\DES.cla ss with an encrypt(String) function. Everything works fine, even when I echo out $des it shows as Object.

However, my last line does not output the encrypt function. Can anyone tell me why?

Also, if I go to run the php script a subsequent time, I get:

Fatal error: Unable to create Java Virtual Machine in c:\instantrails \www\javafromph p.php on line 2

unless I either reboot the computer or restart my apache web server under which php is running. Anyone ever call a java class from php? -R. Vince
Jun 16 '07 #1
2 3264
Rik
On Sat, 16 Jun 2007 14:06:51 +0200, Janna <mi***********@ hotmail.com
wrote:
I have the Java JVM installes on my server.
I created a little php file to test it all out:
<?php
$des = new java("DES","xra y");
echo $des . "<br />";
echo $x . ' = ' . $des->encrypt($x);
?>

Which outputs as:

Object

Note that I have a class file C:\JavaSources\ MyStuff\DES.cla ss with an
encrypt(String) function. Everything works fine, even when I echo out
$des it shows as Object.

However, my last line does not output the encrypt function. Can anyone
tell me why?
To know what $des actually is:
1. var_dump($des);
2. print_r(get_cla ss_methods(get_ class($des)));

Can't help you with the Java bit, never used it.
--
Rik Wasmus
Jun 16 '07 #2
"Janna" <mi***********@ hotmail.comwrot e in
news:46******** *************** @roadrunner.com :
I have the Java JVM installes on my server.

I uncommented
extension=php_j ava.dll
in php.ini

I uncommented and proerpyl filled out the [java] section in php.ini:
[Java]
java.class.path
="C:\InstantRai ls\php\extensio ns\php_java.jar ;C:\JavaSources \MyStuff"
java.home = "C:\Program Files\Java\jdk1 .5.0_10;C:\Prog ram
Files\Java\jre1 .5.0_10\lib" java.library = "C:\Program
Files\Java\jdk1 .5.0_10\jre\bin \server\jvm.dll " java.library.pa th =
"C:\InstantRail s\php\extension s\;C:\Program
Files\Java\jdk1 .5.0_10\jre\lib "
Hi Janna

I've used Java with PHP before and it was a doozy to get going. To sum
it up, you have to make sure that the user under which Apache is running
has access to Java... or all users.

What I did was add the following to "/etc/profile":

pathmunge /usr/java/j2sdk1.4.2_14/bin
pathmunge /usr/java/j2sdk1.4.2_14/jre/bin

**************

Whoa whoa, wait, i just realized you are on Windows. I will leave the
stuff above as reference for people having issues with Linux!

For Windows, try the equivalent (from
http://java.sun.com/j2se/1.4.2/install-windows.html )

.. Update the PATH variable (Optional)

You can run the Java 2 SDK without setting the PATH variable, or you
can optionally set it as a convenience.

Should I set the PATH variable?
Set the PATH variable if you want to be able to conveniently run the
Java 2 SDK executables (javac.exe, java.exe, javadoc.exe, etc.) from
any directory without having to type the full path of the command.
If you don't set the PATH variable, you need to specify the full
path to the executable every time you run it, such as:

C:\j2sdk1.4.2_< version>\bin\ja vac MyClass.java

It's useful to set the PATH permanently so it will persist after
rebooting.

How do I set the PATH permanently?
To set the PATH permanently, add the full path of the
j2sdk1.4.2_<ver sion>\bin directory to the PATH variable. Typically
this full path looks something like C:\j2sdk1.4.2_< version>\bin. Set
the PATH as follows, according to whether you are on Microsoft
Windows NT or 98/2000/ME.

Microsoft Windows NT, 2000, and XP - To set the PATH permanently:

1. Choose Start, Settings, Control Panel, and double-click
System. On Microsoft Windows NT, select the Environment tab; on
Microsoft Windows 2000 select the Advanced tab and then
Environment Variables. Look for "Path" in the User Variables and
System Variables. If you're not sure where to add the path, add
it to the right end of the "Path" in the User Variables. A
typical value for PATH is:

C:\j2sdk1.4.2_< version>\bin

Capitalization doesn't matter. Click "Set", "OK" or "Apply".

The PATH can be a series of directories separated by
semi-colons (;). Microsoft Windows looks for programs in the
PATH directories in order, from left to right. You should only
have one bin directory for a Java SDK in the path at a time
(those following the first are ignored), so if one is already
present, you can update it to j2sdk1.4.2_<ver sion>\bin.

2. The new path takes effect in each new Command Prompt window
you open after setting the PATH variable.
here's another reference:
http://ccism.pc.athabascau.ca/html/vhd/javapath.xml#xp

Good luck!!!!
Jun 19 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
6816
by: Ravi Tallury | last post by:
Hi We are having issues with our application, certain portions of it stop responding while the rest of the application is fine. I am attaching the Java Core dump. If someone can let me know what the issue is. Thanks Ravi
9
3771
by: F. GEIGER | last post by:
I've dev'ed a Python prototype of an app, that besides the internals making it up has a gui. While test-driven dev'ing the app's internals in Python is fun as usual, dev'ing the GUI is not so funny, at least for me. I guess dev'ing a GUI in a test-driven way is not possible, or is it? I'm using wxPython, so if anyone has an idea... For now most of the time I extend and change the gui things, then run it, do the clicks to go thru the...
3
2247
by: Airness | last post by:
Hello, First of all, I don't write or even speak good english, so sorry for all the mistakes of this post. I tried to use Java classes from ASP. I used javareg to register my classes and called that classes from ASP with CreateObject. I did a lot of CreateObject in the whole site. That worked well. But my web site crashed when the load was increasing, contrary to the old version which used COM component.
5
1732
by: c | last post by:
So far it looks like we have these options for calling our java based API from a .NET application: 1) http://www.jnbridge.com, about $500 per machine/developer 2) re-write java app in Visual J++ (Microsoft java) - then it will integrate nicely with .NET. 3) use web services 4) use JNI Option 2 isn't possible, because our java based app is a huge server side
2
5945
by: Radha News | last post by:
Hi, I am looking for reference books/tools/code samples for calling java objects/methods from COM/C++ classes. I am reasonably familiar with JNI. If you have used JNI, please let me know of your experiences and things that I need to watch out. I have used JNI 1.1 and it had several bugs and limitations especially for C++ calling Java. Is the newer version of JNI (version 1.4) any better?
3
5077
by: Jerome Cohen | last post by:
AI am trying to call a third-party web service. this service expects an XML fragment that contains the request plus other parameter. adding the web reference created the syntax below(reference.vb). I changed the data type for the structure that contains the XML data from the default "String" to "xml.xmldocument" to enable easy filling of the data. my client code creates an XML document class, fills the data using standard xml dom...
4
12945
by: simon | last post by:
hello, may have a need shortly to call a java class from a vb.net web app. basically the java class would serve as an email creation/sending function. i realize this all could be done in .net, but i'm just curious as to what needs to be set up to make a call such as this. i realize you can call a java function from sql server and was wondering if wrapping the call to java from a proc would be an easy way to go. preferably i'd like to...
2
6971
by: Jobs | last post by:
Download the JAVA , .NET and SQL Server interview with answers Download the JAVA , .NET and SQL Server interview sheet and rate yourself. This will help you judge yourself are you really worth of attending interviews. If you own a company best way to judge if the candidate is worth of it. http://www.questpond.com/InterviewRatingSheet.zip
0
9689
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9550
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10495
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10032
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7573
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6811
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5469
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5597
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4148
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.