Creating Java Objects

 

This procedure describes how to create a new Java object within a PHP script, which will adopt Java object properties and code assist options.

 

 

Instructions on how to complete a procedure

To create a new Java Object:

  1. Create a new Java instance by typing the following code:

$a= new Java("");

  1. Put the cursor between the quotation marks.
    A Code Assist window will appear with available Java packages. You can manually open the Code Assist box by pressing Ctrl+Space.

  1. Select the required java package and press enter.

  2. Type a period "." after the selected java package to activate the code assist options within that package.

  1. Continue with the Code Completion procedure until the appropriate class has been selected.

 

 

The PHP variables that the Java objects have been assigned to will assume the properties and methods of the Java class. When creating new instances of the java class, java code assist options will therefore be available.

 

 

Usage Example

Example:

  1. After the line above, create a new instance of the created PHP object (in this case, $a).

$a->

  1. Place your cursor after the -> and activate Code Assist by clicking Ctrl+Space.
    The Code Assist list will be displayed with java code completion:

Zend Studio stores Java variables in the same way as PHP variables, allowing for code completion functionality for nested method invocation:

 

 

 

 

 

Related Links

Related Links:
Using Java Bridge

Adding External Java Archives

Changing Projects' JREs

Installed JREs Preferences