Java

Java is a Perl extension for accessing a JVM remotely or locally.
Download

Java Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Mark Ethan Trostler
  • Publisher web site:
  • http://search.cpan.org/~metzzo/Java-4.7/Java.pm

Java Tags


Java Description

Java is a Perl extension for accessing a JVM remotely or locally. Java is a Perl extension for accessing a JVM remotely or locally.SYNOPSIS use Java; $java = new Java; $frame = $java->create_object("java.awt.Frame","Frame's Title"); $frame->setSize(400,400); $frame->show(); $java->do_event($frame,"addWindowListener",&event_handler); $array = $java->create_array("java.lang.String",5); // Set array element 3 to "Java is lame" $array-> = "Java is lame"; $element_value = $array->->get_value(); $button = $java->create_object("java.awt.Button","Push Me"); // Listen for 'Action' events from $button object $java->do_event($button,"addActionListener",&event_handler); // Loop & wait mode while(1) { my $continue = $java->go; last if (!defined $continue); } // Got an event! sub event_handler { my($object_that_caused_event,$event_object) = @_; if ($object_that_caused_event->same($button)) { // From $button! print "You pushed my button!!n"; } }This module allows you to talk to a JVM on a local or remote machine. You can create objects, call functions, access fields, deal with arrays, get events & all the nonsense you can do in Java - from Perl!Starting a JVM serverFirst you must run 'JavaServer' on the machine to which you will make connections. Simply do a 'java JavaServer' to start the server. By default it will start listening on port 2000. Make sure the 'JavaServer.jar' is in your classpath - also make sure the Swing stuff (JFC if you prefer) is in your classpath as well if you want to use Swing stuff (note this does not apply to JVM 1.2+).Creating the root Java objectYou connect to a remote (or local) JVM when you create a new Java instance. The new call accepts a hash with the following keys: host => hostname of remote machine to connect to default is 'localhost' port => port the JVM is listening on (JavaServer) default is 2000 event_port => port that the remote JVM will send events to default is 2001. If you specify '-1' for this value then the event service will be turned off - if you're not doing any GUI work this might be a good idea as the second event port will NOT get used/opened saving some system resources. authfile => The path to a file whose first line is used as a shared 'secret' which will be passed to JavaServer. To use this feature you must start JavaServer with the '--authfile=' command-line option. If the secret words match access will be granted to this client. By default there is no shared secret. See the 'Authorization' section below. use_old_style_arrays => tell Java.pm to use 'old-style' arrays which you should NOT be using unless you need backwards compatibility with 3.x Java.pm & earlier. By default all arrays returned by JavaServer are 'tied' to the JavaArray class for easier perl-like manipulation. See the 'Arrays' section futher down for more info.For example: $java = new Java(host => "java.zzo.com", event_port => 4032); # No events! $java2 = new Java(port => 8032, event_port => -1);You can have any number of java 'environments' in a Perl program.Requirements:· Perl Requirements: · Perl


Java Related Software