在 Eclipse Indigo 中使用 ANT 时出现 javah NullPointerException [英] javah NullPointerException while using ANT in Eclipse Indigo

查看:28
本文介绍了在 Eclipse Indigo 中使用 ANT 时出现 javah NullPointerException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用这样的 ANT 构建脚本:

I'm using an ANT buildscript like so:

<project basedir="..">
<property name="src" location="src"/>
<property name="classes" location="classes" />
<property name="jnifiles" location="jnifiles" />

<target name="init">
    <mkdir dir="${classes}" />
    <mkdir dir="${jnifiles}" />
</target>

<target name="compile" 
    description="compile the source " >
    <javac srcdir="${src}" destdir="${classes}" includeantruntime="false" />
</target>

<target name="generate-jni">
    <javah destdir="${jnifiles}" >
        <class name="com.example.ExecJNI" />
    </javah>
</target>

<target name="clean"
    description="clean up" >
    <delete dir="${classes}"/>
    <delete dir="${jnifiles}"/>
</target>

它通过干净、初始化和编译就好了,但是在 generate-jni 时我收到以下错误:

It goes through clean, init and compile just fine, but at generate-jni I get the following error:

generate-jni:
   [javah] Exception in thread "main" java.lang.NullPointerException
   [javah]  at com.sun.tools.javah.JavahTask.run(JavahTask.java:509)
   [javah]  at com.sun.tools.javah.JavahTask.run(JavahTask.java:335)
   [javah]  at com.sun.tools.javah.Main.main(Main.java:46)

有人知道我做错了什么吗?

Anyone have a clue what I'm doing wrong?

推荐答案

您是否检查了已安装 JRE 的默认版本?

Did you check the default version of installed JREs?

我也遇到了同样的问题,我在 Eclipse 首选项中检查了已安装的 JRE.虽然我确实安装了 jdk1.7,但默认版本是 jre7.修改默认版本为jdk1.7后,问题解决.

I had the same problem too and I checked installed JREs in Eclipse preferences. The default version is jre7 though I indeed installed jdk1.7. After changing the default version to jdk1.7, the problem is solved.

希望这些信息对您有所帮助.

Hope this information helps you.

这篇关于在 Eclipse Indigo 中使用 ANT 时出现 javah NullPointerException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆