Next: , Previous: How to make Java classes available?, Up: FAQ - Frequently asked Questions


37.3.3 How to create an instance of a Java class?

If your code shall work under Octave as well as matlab you should use the function javaObject to create Java objects. The function java_new is Octave specific and does not exist in the matlab environment.

Example 1, suitable for Octave but not for matlab:

        Passenger = java_new('package.FirstClass', row, seat);

Example 2, which works in Octave as well as in matlab:

        Passenger = javaObject('package.FirstClass', row, seat);