목차
Windows Installation
php教程 php手册 PHP & Java(1)

PHP & Java(1)

Jun 06, 2016 pm 07:55 PM
amp java php s

Mark Nold Joost Soeterbroek The Java extension is an extremely exciting tool. By learning how to use this module, you can extend PHP by the power of all available Java classes. To show you the basics of the Java extension, this article wil

Mark Nold
Joost Soeterbroek

The Java extension is an extremely exciting tool. By learning how to use this module, you can extend PHP by the power of all available Java classes. To show you the basics of the Java extension, this article will cover installation and a few code examples of using PHP and Java together.

Windows Installation

The following configuration has been tested with Apache 1.3.12, PHP 4.0.3 binaries from www.php4win.de plus the 4.0.3 Zend Optimiser and JDK 1.2.2 from java.sun.com. We have also tested this configuration with older versions of the JDK and the various MS webservers (PWS and IIS) on Windows 95, Windows 98 and NT4.

Step 1: Install the JDK. This is fairly simple, as the JDK installs without many questions. It might be useful to check your environment (autoexec.bat in Windows 9x and System under Control Panel in NT) and make sure the jdk1.x.x/bin directory is in your path. This will make compiling your Java Classes easier. On Win9x add

PATH=%PATH%;C:/jdk1.2.2/bin
로그인 후 복사
to your autoexec.bat. On NT add
;C:/jdk1.2.2/bin
로그인 후 복사
to the end of the PATH environment variable. It is also important to note in your autoexec.bat file, the PHP Java extension ignores the JAVA_HOME and CLASSPATH set up in the environment. This is important because these items must be set correctly in your php.ini file for the Java extension to work.

Step 2: Modifying your php.ini. You need to add something similiar to your php.ini file

[java]
extension=php_java.dll
java.library.path=c:/web/php4/extensionsjava.class.path="c:/web/php4/extensions/jdk1.2.2/php_java.jar;c:/myclasses"
로그인 후 복사

Typically, people put the extension=php_java.dll directive with the rest of the extensions, but it can sit happily under [java]. The java.library.path must be set in the location of the php_java.dll, and java.class.path must include the location of php_java.jar. The java.class.path should also include the path to other classes you may wish to use (note the double quotes!). In these examples, we will be talking about c:/myclasses. You should also note that the single period is ignored by PHP and Java. As far as we know, you cannot set PHP to look in the current directory for its Java classes.

Step 3: Testing your Install. Now, you're ready to go. Create a PHP file that looks something like this:

<code>
<?php $system = new Java("java.lang.System");
  print "Java version=".$system->getProperty("java.version")." <br>/n";
  print "Java vendor=".$system->getProperty("java.vendor")." <p>/n/n";
  print "OS=".$system->getProperty("os.name")." ".
              $system->getProperty("os.version")." on ".
              $system->getProperty("os.arch")." <br>/n";

  $formatter = new Java("java.text.SimpleDateFormat","EEEE, 
	MMMM dd, yyyy 'at' h:mm:ss a zzzz");
  print $formatter->format(new Java("java.util.Date"))."/n";
  
?>
</p></code>
로그인 후 복사

NB: This is taken directly from Sam Ruby's examples. If you have correctly installed everything, you should see some results like:

Java version=1.2.2 
Java vendor=Sun Microsystems Inc. 
OS=Windows 95 4.10 on x86 
Wednesday, October 18, 2000 at 10:22:45 AM China Standard Time 
로그인 후 복사

A very simple example, but it shows you can access currently available Java classes. Once you have this example working, you have successfully set up the PHP Java extension.

본 웹사이트의 성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.

핫 AI 도구

Undresser.AI Undress

Undresser.AI Undress

사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover

AI Clothes Remover

사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool

Undress AI Tool

무료로 이미지를 벗다

Clothoff.io

Clothoff.io

AI 옷 제거제

Video Face Swap

Video Face Swap

완전히 무료인 AI 얼굴 교환 도구를 사용하여 모든 비디오의 얼굴을 쉽게 바꾸세요!

인기 기사

<gum> : Bubble Gum Simulator Infinity- 로얄 키를 얻고 사용하는 방법
3 몇 주 전 By 尊渡假赌尊渡假赌尊渡假赌
Nordhold : Fusion System, 설명
4 몇 주 전 By 尊渡假赌尊渡假赌尊渡假赌
Mandragora : 마녀 트리의 속삭임 - Grappling Hook 잠금 해제 방법
3 몇 주 전 By 尊渡假赌尊渡假赌尊渡假赌

뜨거운 도구

메모장++7.3.1

메모장++7.3.1

사용하기 쉬운 무료 코드 편집기

SublimeText3 중국어 버전

SublimeText3 중국어 버전

중국어 버전, 사용하기 매우 쉽습니다.

스튜디오 13.0.1 보내기

스튜디오 13.0.1 보내기

강력한 PHP 통합 개발 환경

드림위버 CS6

드림위버 CS6

시각적 웹 개발 도구

SublimeText3 Mac 버전

SublimeText3 Mac 버전

신 수준의 코드 편집 소프트웨어(SublimeText3)

session_start ()가 여러 번 호출되면 어떻게됩니까? session_start ()가 여러 번 호출되면 어떻게됩니까? Apr 25, 2025 am 12:06 AM

Session_Start ()로 여러 통화를하면 경고 메시지와 가능한 데이터 덮어 쓰기가 발생합니다. 1) PHP는 세션이 시작되었다는 경고를 발행합니다. 2) 세션 데이터의 예상치 못한 덮어 쓰기를 유발할 수 있습니다. 3) Session_status ()를 사용하여 반복 통화를 피하기 위해 세션 상태를 확인하십시오.

작곡가 : AI를 통한 PHP 개발 지원 작곡가 : AI를 통한 PHP 개발 지원 Apr 29, 2025 am 12:27 AM

AI는 작곡가 사용을 최적화하는 데 도움이 될 수 있습니다. 특정 방법에는 다음이 포함됩니다. 1. 종속성 관리 최적화 : AI는 종속성을 분석하고 최상의 버전 조합을 권장하며 충돌을 줄입니다. 2. 자동화 된 코드 생성 : AI는 모범 사례를 준수하는 composer.json 파일을 생성합니다. 3. 코드 품질 향상 : AI는 잠재적 인 문제를 감지하고 최적화 제안을 제공하며 코드 품질을 향상시킵니다. 이러한 방법은 기계 학습 및 자연어 처리 기술을 통해 구현되어 개발자가 효율성과 코드 품질을 향상시킬 수 있도록 도와줍니다.

session_start () 함수의 중요성은 무엇입니까? session_start () 함수의 중요성은 무엇입니까? May 03, 2025 am 12:18 AM

session_start () iscrucialinphpformanagingUsersessions.1) itiniteSanewsessionifnoneexists, 2) ResumesAnxistessions, and3) setSasessionCookieForContInuityAcrosrequests, enablingplicationsirecationSerauthenticationAndpersonalizestContent.

'플랫폼 독립성'은 Java의 맥락에서 무엇을 의미합니까? '플랫폼 독립성'은 Java의 맥락에서 무엇을 의미합니까? Apr 23, 2025 am 12:05 AM

Java의 플랫폼 독립성은 작성된 코드가 수정없이 JVM이 설치된 모든 플랫폼에서 실행될 수 있음을 의미합니다. 1) Java 소스 코드는 바이트 코드로 컴파일됩니다. 2) 바이트 코드는 JVM에 의해 해석되고 실행됩니다.

H5 : HTML5의 주요 개선 H5 : HTML5의 주요 개선 Apr 28, 2025 am 12:26 AM

HTML5는 5 가지 주요 개선 사항을 제공합니다. 1. 시맨틱 태그는 코드 선명도 및 SEO 효과를 향상시킵니다. 2. 멀티미디어 지원은 비디오 및 오디오 임베딩을 단순화합니다. 3. 형태 향상은 검증을 단순화한다. 4. 오프라인 및 로컬 스토리지는 사용자 경험을 향상시킵니다. 5. 캔버스 및 그래픽 기능은 웹 페이지의 시각화를 향상시킵니다.

데이터 처리 및 계산에 MySQL 기능을 사용하는 방법 데이터 처리 및 계산에 MySQL 기능을 사용하는 방법 Apr 29, 2025 pm 04:21 PM

MySQL 기능은 데이터 처리 및 계산에 사용될 수 있습니다. 1. 기본 사용에는 문자열 처리, 날짜 계산 및 수학 연산이 포함됩니다. 2. 고급 사용에는 복잡한 작업을 구현하기 위해 여러 기능을 결합하는 것이 포함됩니다. 3. 성능 최적화를 위해서는 WHERE 절에서 기능 사용 및 GroupBy 및 임시 테이블 사용을 피해야합니다.

작곡가 : PHP 개발자의 패키지 관리자 작곡가 : PHP 개발자의 패키지 관리자 May 02, 2025 am 12:23 AM

Composer는 PHP의 종속성 관리 도구이며 Composer.json 파일을 통해 프로젝트 종속성을 관리합니다. 1) 종속성 정보를 얻기 위해 Composer.json을 구문 분석합니다. 2) 종속성 트리를 형성하기위한 종속성; 3) Packagist에서 공급 업체 디렉토리로 종속성을 다운로드하여 설치합니다. 4) Composer.Lock 파일을 생성하여 팀 일관성 및 프로젝트 유지 관리 가능성을 보장하기 위해 종속성 버전을 잠그십시오.

Java의 플랫폼 별 코드 작성 상황에 대해 토론하십시오. Java의 플랫폼 별 코드 작성 상황에 대해 토론하십시오. Apr 25, 2025 am 12:22 AM

Java에서 플랫폼 별 코드를 작성하는 이유에는 특정 운영 체제 기능에 대한 액세스, 특정 하드웨어와 상호 작용하고 성능 최적화가 포함됩니다. 1) JNA 또는 JNI를 사용하여 Windows 레지스트리에 액세스하십시오. 2) JNI를 통한 Linux 특이 적 하드웨어 드라이버와 상호 작용; 3) 금속을 사용하여 JNI를 통해 MacOS의 게임 성능을 최적화하십시오. 그럼에도 불구하고 플랫폼 별 코드를 작성하면 코드의 이식성에 영향을 미치고 복잡성을 높이며 잠재적으로 성능 오버 헤드 및 보안 위험을 초래할 수 있습니다.

See all articles