JavaプロジェクトをJavaプロジェクトにビルドするとき(デフォルトの「実行」で)、プログラムは正常に起動します。警告またはエラーはありません。JARでのAnt build.xmlの問題
しかし、外部のライブラリ(たとえばswingx、日付選択)の機能を使用するまでは、端末(java -jar ...)からantでビルドされたJARを実行すると、すべてがうまく見えます。大規模なexcptionがthownさ:
ここException in thread "AWT-EventQueue-0" java.lang.NullPointerException
at org.jdesktop.swingx.plaf.basic.BasicMonthViewUI.getTraversableGridPositionAtLocation(BasicMonthViewUI.java:906)
at org.jdesktop.swingx.plaf.basic.BasicMonthViewUI$Handler.mousePressed(BasicMonthViewUI.java:1723)
at java.awt.Component.processMouseEvent(Component.java:6501)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3321)
at java.awt.Component.processEvent(Component.java:6269)
at java.awt.Container.processEvent(Container.java:2229)
at java.awt.Component.dispatchEventImpl(Component.java:4860)
at java.awt.Container.dispatchEventImpl(Container.java:2287)
at java.awt.Component.dispatchEvent(Component.java:4686)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4832)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4489)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4422)
at java.awt.Container.dispatchEventImpl(Container.java:2273)
at java.awt.Window.dispatchEventImpl(Window.java:2713)
at java.awt.Component.dispatchEvent(Component.java:4686)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:707)
at java.awt.EventQueue.access$000(EventQueue.java:101)
at java.awt.EventQueue$3.run(EventQueue.java:666)
at java.awt.EventQueue$3.run(EventQueue.java:664)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87)
at java.awt.EventQueue$4.run(EventQueue.java:680)
at java.awt.EventQueue$4.run(EventQueue.java:678)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:677)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:211)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:128)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:117)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:113)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:90)
は私のアリのbuild.xmlです:
<project name="Jamm" basedir="." default="run">
<property name="src.dir" value="src" />
<property name="build.dir" value="build" />
<property name="classes.dir" value="${build.dir}/classes" />
<property name="jar.dir" value="${build.dir}/jar" />
<property name="lib.dir" value="lib" />
<property name="main-class" value="jamm.Main" />
<buildnumber file="build.num" />
<property name="res.dir.name" value="res" />
<property name="res.dir" value="${src.dir}/${res.dir.name}" />
<property file="${res.dir}/version_num.properties" />
<property name="jar.filename" value="${ant.project.name}_v${versionnumber}-b${build.number}.jar" />
<tstamp>
<format property="TODAY" pattern="yyyy-MM-dd HH:mm:ss" />
</tstamp>
<path id="classpath">
<fileset dir="${lib.dir}" includes="**/*.jar" />
</path>
<target name="clean">
<delete dir="${build.dir}" />
</target>
<target name="compile" depends="clean">
<mkdir dir="${classes.dir}" />
<javac srcdir="${src.dir}" destdir="${classes.dir}" classpathref="classpath" includeantruntime="true"/>
</target>
<target name="dist" depends="compile">
<mkdir dir="${jar.dir}" />
<jar destfile="${jar.dir}/${jar.filename}" basedir="${classes.dir}">
<restrict>
<name name="**/*.class" />
<archives>
<zips>
<fileset dir="${lib.dir}" includes="**/*.jar" />
</zips>
</archives>
</restrict>
<manifest>
<attribute name="Main-Class" value="${main-class}" />
<attribute name="Built-By" value="${user.name}" />
<attribute name="Build-Version" value="v${versionnumber}_b${build.number}" />
<attribute name="Built-Date" value="${TODAY}" />
</manifest>
<fileset dir="${src.dir}">
<include name="${res.dir.name}/**/*" />
</fileset>
</jar>
</target>
<target name="run" depends="dist">
<java fork="true" classname="${main-class}">
<classpath>
<path refid="classpath" />
<path location="${jar.dir}/${jar.filename}" />
</classpath>
</java>
</target>
私も、コンソール上で、Eclipseの、その作品からrunable JARをエクスポートします。
org.jdesktop.swingx.plaf.basic.BasicMonthViewUI.getTraversableGridPositionAtLocation(BasicMonthViewUI.java:906)のnullは何ですか? – oers