javah NullPointerException while using ANT in Eclipse Indigo

为君一笑 提交于 2020-01-07 05:38:28

问题


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>

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?


回答1:


Did you check the default version of installed JREs?

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.



来源:https://stackoverflow.com/questions/15054079/javah-nullpointerexception-while-using-ant-in-eclipse-indigo

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!