Java API bindings
Presentation
-The Java bindings are currently a work in progress based mostly -on the work of Toth Istvan. The first usable release is 0.2.0, where -most of the naming conventions were defined. Further release will try -as much as possible to stay compatible
+The Java bindings make use of JNA + to expose the C API in a Java friendly way. The bindings are are based on + work initiated by Toth Istvan.
Getting it
The latest versions of the libvirt Java bindings can be downloaded from:
-Hourly development snapshots
-Once an hour, an automated snapshot is made from the latest CVS server - source tree. These snapshots should be usable, but we make no guarantees - about their stability:
- -CVS repository access
-The master source repository uses CVS and anonymous access +
Maven
+A maven repository is located at http://www.libvirt.org/maven2/ +which you can use to include this in your maven projects.
+GIT source repository
+The Java bindings code source is now maintained in a git repository available on +libvirt.org: +
++git clone git://libvirt.org/libvirt-java.git ++
+It can also be browsed at +
++ +http://libvirt.org/git/?p=libvirt-java.git;a=summary ++ +
GIT repository mirror
++ The source code is also mirrored on gitorious + to aid in public development. You clone the repo with +
++ git clone git://gitorious.org/libvirt/libvirt-java.git ++
+ It can also be browsed at +
++ + http://gitorious.org/libvirt/libvirt-java ++ +
CVS repository access (Deprecated)
+ The old source repository uses CVS and anonymous access
is provided. Prior to accessing the server is it necessary to authenticate
using the password anoncvs
. This can be accomplished with
the cvs login
command:
@@ -134,47 +162,20 @@ the cvs login
command:
Once authenticated, a checkout can be obtained using
- # cvs -d :pserver:anoncvs@libvirt.org:2401/data/cvs co libvirt-java-
-The libvirt-java build process uses GNU autotools, so after obtaining a checkout
-it is necessary to generate the configure script and Makefile.in templates
-using the autogen.sh
command. As an example, to do a complete
-build and install it into your home directory run:
-
- ./autogen.sh --prefix=$HOME/usr - make - make install --
Other build system are not currently available but as usual we take patches -(Eclipse/ant/...) would be welcome !
-currently libvirt-java requires a version of libvirt >= 0.4.0 to be -installed as well as the associated libvirt development files/package. It -should compile with any java implementation >= 1.5, the bindings uses -the enum construct which appeared only in that version.
-Libvirt-java bindings development occurs on the same mailing-list as -the normal libvirt work see the associated contact -page
-GIT repository mirror
-- The CVS source repository is also mirrored using GIT, and is available - for anonymous access via: -
-- git clone git://git.et.redhat.com/libvirt-java --
- It can also be browsed at -
+ +Building
+The code is built using ant, and assumes that you have the jna jar installed. Once you have downloaded +the code you can build the code with
- http://git.et.redhat.com/?p=libvirt-java.git;a=summary +% cd libvirt-java +% ant build
Content
The bindings are articulated around a few
-classes in the org/libvirt
namespace, notably the
+classes in the org/libvirt
package, notably the
Connect
, Domain
and Network
ones. Functions in the C API
taking virConnectPtr
, virDomainPtr
or
@@ -192,13 +193,13 @@ lower case, for example the C functions:
become
- virConn::numOfDomains()
+ virConn.numOfDomains()
- virDomain::setMaxMemory(long memory)
+ virDomain.setMaxMemory(long memory)
There is of course some functions where the mapping is less direct -and using extra classes to map complex arguments. The Javadoc is available online or as +and using extra classes to map complex arguments. The Javadoc is available online or as part of a separate libvirt-java-javadoc package.
So let's look at a simple example inspired from the
test.java
test found in src
in the source tree:
There is not much to comment about it, it really is a straight mapping from the C API, the only points to notice are:
-- the import of the modules in the
org.libvirt
namespace - getting a connection to the hypervisor, in that case using the
+
- the import of the modules in the
org.libvirt
package - getting a connection to the hypervisor, in that case using the readonly access to the default test hypervisor.
- getting an object representing the test domain using lookupByName
- if the domain is not found a LibvirtError exception will be raised
- extracting and printing some information about the domain using various methods associated to the Domain class.
Java API bindings
Presentation
-The Java bindings are currently a work in progress based mostly -on the work of Toth Istvan. The first usable release is 0.2.0, where -most of the naming conventions were defined. Further release will try -as much as possible to stay compatible
+The Java bindings make use of JNA + to expose the C API in a Java friendly way. The bindings are are based on + work initiated by Toth Istvan.
Getting it
@@ -19,19 +18,51 @@ as much as possible to stay compatible
- the import of the modules in the
- libvirt.org HTTP server
Hourly development snapshots
-Once an hour, an automated snapshot is made from the latest CVS server - source tree. These snapshots should be usable, but we make no guarantees - about their stability:
+Maven
+A maven repository is located at http://www.libvirt.org/maven2/ +which you can use to include this in your maven projects.
- +GIT source repository
+The Java bindings code source is now maintained in a git repository available on +libvirt.org: +
++git clone git://libvirt.org/libvirt-java.git ++
+It can also be browsed at +
+--CVS repository access
+http://libvirt.org/git/?p=libvirt-java.git;a=summary +
The master source repository uses
+GIT repository mirror
+ ++ The source code is also mirrored on gitorious + to aid in public development. You clone the repo with +
+ ++ git clone git://gitorious.org/libvirt/libvirt-java.git ++ +
+ It can also be browsed at +
+ ++ + http://gitorious.org/libvirt/libvirt-java ++ + +
CVS repository access (Deprecated)
+ + The old source repository uses CVS and anonymous access
is provided. Prior to accessing the server is it necessary to authenticate
using the password anoncvs
. This can be accomplished with
@@ -47,54 +78,24 @@ the cvs login
command:
- # cvs -d :pserver:anoncvs@libvirt.org:2401/data/cvs co libvirt-java-
-The libvirt-java build process uses GNU autotools, so after obtaining a checkout
-it is necessary to generate the configure script and Makefile.in templates
-using the autogen.sh
command. As an example, to do a complete
-build and install it into your home directory run:
-
- ./autogen.sh --prefix=$HOME/usr - make - make install --
Other build system are not currently available but as usual we take patches -(Eclipse/ant/...) would be welcome !
-currently libvirt-java requires a version of libvirt >= 0.4.0 to be -installed as well as the associated libvirt development files/package. It -should compile with any java implementation >= 1.5, the bindings uses -the enum construct which appeared only in that version.
-Libvirt-java bindings development occurs on the same mailing-list as -the normal libvirt work see the associated contact -page
- -GIT repository mirror
- -- The CVS source repository is also mirrored using GIT, and is available - for anonymous access via: -
- -- git clone git://git.et.redhat.com/libvirt-java -- -
- It can also be browsed at -
+ +Building
+The code is built using ant, and assumes that you have the jna jar installed. Once you have downloaded +the code you can build the code with
- http://git.et.redhat.com/?p=libvirt-java.git;a=summary +% cd libvirt-java +% ant build+
Content
The bindings are articulated around a few
-classes in the org/libvirt
namespace, notably the
+classes in the org/libvirt
package, notably the
Connect
, Domain
and Network
ones. Functions in the C API
taking virConnectPtr
, virDomainPtr
or
@@ -112,13 +113,13 @@ lower case, for example the C functions:
become
- virConn::numOfDomains()
+ virConn.numOfDomains()
- virDomain::setMaxMemory(long memory)
+ virDomain.setMaxMemory(long memory)
There is of course some functions where the mapping is less direct -and using extra classes to map complex arguments. The Javadoc is available online or as +and using extra classes to map complex arguments. The Javadoc is available online or as part of a separate libvirt-java-javadoc package.
So let's look at a simple example inspired from the
test.java
test found in src
in the source tree:
There is not much to comment about it, it really is a straight mapping from the C API, the only points to notice are:
-
-
- the import of the modules in the
org.libvirt
namespace
+ - the import of the modules in the
org.libvirt
package - getting a connection to the hypervisor, in that case using the readonly access to the default test hypervisor.
- getting an object representing the test domain using lookupByName