环境centos6.0,kvm虚拟化环境并已安装libvirt,部署详见http://blog.csdn.net/gg296231363/article/details/6891460
以下是安装Libvirt-java的简单过程
1 JDK环境配置 /usr/java/jdk1.6.0_20 路径
详见http://blog.csdn.net/gg296231363/article/details/6899610
2 安装 ant 类似于makfile的工具
yum -y install ant
3 下载安装包
wget http://libvirt.org/sources/java/libvirt-java-0.4.7.tar.gz
tar zxvf libvirt-java-0.4.7.tar.gz
进入目录
ant build
4 产生的*.jar文件在 ./target目录下
cp ./target/libvirt-0.4.7.jar /usr/share/java/
ln -s /usr/share/java/libvirt-0.4.7.jar libvirt.jar
如已有libvirt-0.4.5->libvirt.jar,先删除低版本,再按如上操作
解决一个警告:
build:
[javac] /home/guodd/libvirt/libvirt-java/build.xml:39: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds
[javac] /home/guodd/libvirt/libvirt-java/build.xml:40: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds
原因是ant要求设置ant运行时间
vi build.xml 39,40行中都添加 includeantruntime="false",如下:
<target name="build" depends="init" description="builds the code and jar files">
<javac srcdir="src/main/java" includeantruntime="false" includes="**/*.java" classpathref="compile.classpath" destdir="target/classes" />
<javac srcdir="src/test/java" includeantruntime="false" includes="**/*.java" classpathref="test.classpath" destdir="target/testclasses" />
<jar destfile="${jar.file}" basedir="target/classes" />
</target>