双击可执行Jar文件没反应---我没辙

mituzhishi mituzhishi 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
源文件:

/*
* Created on 2005-3-30
*/
package a.b;

/**
* @author Mituzhishi
*/
public class Ch05_02 {

public static void main(String[] args) {
System.out.println("This code was built using Ant.");

}
}




build.xml:

<?xml version="1.0"?>

<!-- ===================================================================== -->
<!-- My test -->
<!-- Ant 1.6.2 build file -->
<!-- ===================================================================== -->

<project name="test" default="build" basedir=".">

<property name="srcdir" value="a"/>
<property name="destdir" value="build"/>
<property name="docdir" value="doc"/>

<!-- Allow user to override properties without editing this file -->
<property file="${user.home}/.ant.properties" />


<!-- ================================================================= -->
<!-- Compile -->
<!-- ================================================================= -->
<target name="compile" description="Compiles the source code for my project">

<mkdir dir="${destdir}"/>

<javac srcdir="${srcdir}"
destdir="${destdir}"
debug="on" >

<include name="**/*.java"/>
</javac>

</target>


<!-- ================================================================= -->
<!-- Clean -->
<!-- ================================================================= -->
<target name="clean" description="Deletes the build directory for my project">
<delete dir="${destdir}" failonerror="false" />
</target>


<!-- =================================================================== -->
<!-- Build -->
<!-- =================================================================== -->
<target name="build" depends="clean, compile" description="Compiles and creates the Jar file">

<jar jarfile="${basedir}/test.jar">
<manifest>
<attribute name="Main-Class"
value="a.b.Ch05_02"/>
</manifest>

<fileset dir="${destdir}" includes="**/*.class"/>
</jar>

</target>


<!-- =================================================================== -->
<!-- Javadoc -->
<!-- =================================================================== -->
<target name="javadoc" description="Creates API documentation (JavaDocs) for my project">

<delete dir="${docdir}" failonerror="false"/>
<mkdir dir="${docdir}"/>

<javadoc
destdir="${docdir}"
access="private"
author="true"
version="true"
use="true">

<fileset dir="${srcdir}">
<include name="*.java"/>
</fileset>

<link href="http://java.sun.com/j2se/1.4.2/docs/api/"/>

</javadoc>

</target>

</project>


manifest:

Manifest-Version: 1.0
Ant-Version: Apache Ant 1.6.2
Created-By: 1.4.2-b28 (Sun Microsystems Inc.)
Main-Class: a.b.Ch05_02


最终生成的Jar文件中有a.b.Ch05_02.class这个文件
可是双击就是没反应,
我以前做的可执行Jar文件都可以的
怀疑是源文件中使用了包的缘故

...全文
评论 10
收藏 已收藏
分享
返回顶部
mituzhishi
Java SE 62,621 成员 307,251 内容