|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #24204 --with-java does not compile on Mac OS X
Submitted: 2003-06-16 07:10 UTC Modified: 2003-10-30 21:13 UTC
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: php_public at macfreek dot nl Assigned:
Status: Wont fix Package: Java related
PHP Version: 4.3.2 OS: Mac OS X (10.2.6)
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: php_public at macfreek dot nl
New email:
PHP Version: OS:


 [2003-06-16 07:10 UTC] php_public at macfreek dot nl
In short, Java does not compile on Mac OS X, because 
the Java headers are at an other location then java.c 
expects them. configure does work.

Reproduce code:
On Mac OS X (Darwin):
./configure --with-java=/usr (you can leave the =/usr out).

Actual result:
JavaVM/jni.h: No such file or directory

This is due to this code:
#include <JavaVM/JavaVM.h>
#include <JavaVM/jni.h>
#define JNI_12
#include <jni.h>

In php_config.h, the precompiler directive 
HAVE_JAVAVM_JAVAVM_H was set, even though there is no 
file on my system called JavaVM/JavaVM.h

As an ugly workaround, specifying the full path did 
#include </System/Library/Frameworks/JavaVM.framework/
#include </System/Library/Frameworks/JavaVM.framework/

Apparently, jni.h is not in Java VM 1.4.1, which is 
also installed on Mac OS X. But to be honest, I got 
crazy about all symbolic links in /System/Library/


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2003-06-16 07:43 UTC]
The short of it is, those files are needed, but I believe you're misunderstanding how frameworks work.  By specifying the full path you are (potentially) invalidating future release of the JavaVM framework.  

The proper answer is to figure out why the jni.h file is not being used by JavaVM framework.  I'll try to reproduce it later today.
 [2003-06-16 12:43 UTC] php_public at macfreek dot nl
Oh yes, this is not the proper fix! That's why I called 
it an *ugly* workaround. ;-)

By the way, the file in php-4.3.2/sapi/servlet/
servlet.c will most likely have the same problem.

I would have expected Apple to have made a symbolic 
link from /usr/include/JavaVM/jni.h to whereever the 
file may reside in the most current release. However, 
that is not the case, and Java seem to be installed, so 
we apparently have to deal with whatever is available. 
The correct solution is probably to add the appropriate 
-I option to the linker, by altering the configure 
 [2003-06-26 15:16 UTC]
Oddly enough this only occurs while building the CLI, I can build the CGI just fine.  It looks like the -framework JavaVM is being lost in the CLI version of the build.

Is there someone more knowledgable with the build structure, more specifically the CLI, that can shed a little light on this?

 [2003-08-05 15:56 UTC] thesin at users dot sf dot net
java builds fine on OSX, this is the how to

./configure --with-java=/System/Library/Frameworks/

I chose 1.3.1 for compat, if you have 1.4.1 it can be 

Patch the source like so:
  perl -pi -e 's,DL_FETCH_SYMBOL\(dl_handle\, 
\"_JNI_CreateJavaVM_Impl\"\),g' ext/java/java.c  perl 
-pi -e 's,DL_FETCH_SYMBOL\(dl_handle\, 
handle\, \"_JNI_GetDefaultJavaVMInitArgs_Impl\"\),g' 

and finally the config (php.ini):
java.home = /System/Library/Frameworks/
java.library = /System/Library/Frameworks/

of course the java.class.path should equal the full 
path to php_java.jar

and I haven't figured out the java.library.path yet 
from what I've read it should point to the path where is created and you should make a 
symlink to (Shared version)

this will get you to this error when I use the java 
stuff in a php file:

  $system = new Java("java.lang.System");
  printf("Java version = %s\n", $system-

Fatal error:  java.lang.UnsatisfiedLinkError: no 
php_java in java.library.path

from reading it seems that LD_LIBRARY_PATH needs to be 
set but that env var doesn't exist on OS X, in it's 
place there is DYLD_LIBRARY_PATH and LIBRARY_PATH but 
neither fixed it for me, if anyone can figure this out 
please email me.
 [2003-08-05 16:49 UTC]
I'm going to unassign this to me, as I have yet to find any solutions in the CLI, and hopefully someone else will.

As I said before, with the configure script everything is able to compile just fine, as long as you don't build the CLI interface at the same time.  The hackery proposed above may indeed work, but I don't see a reason for it.  The same can be accomplished with a simple ./configure option.

I still ask that any PHP developer familiar with the buildsystem or CLI look into why some flags are not being used by it while the CGI works just fine.
 [2003-10-30 21:13 UTC]
Java extension in PHP 4 does not work even if you could compile it. Will not be fixed in PHP 4. PHP 5 might have working Java support.

PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Sat Jun 12 19:01:24 2021 UTC