如何建立,需要一个外部罐子,用蚂蚁的小程序? [英] How do I build an applet which needs an external jar, using ant?

查看:146
本文介绍了如何建立,需要一个外部罐子,用蚂蚁的小程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经写了一个Java小程序是pretty简单。它在点击一个按钮连接到Oracle数据库。它工作正常,当我运行它使用Eclipse它连接。

然而,当我使用ant创建jar文件,我不知道如何包含ojdbc6.jar的类路径。
我会怎么做呢?

下面是我的Ant构建文件。我需要我的外部第三方jar文件在C:\\ jarfiles中

 <项目默认为罐子>
  <属性名=构建值=构建/>
  <属性名=java.homeVALUE =C:\\ Program Files文件/的Java / jdk1.6.0_10/>
  <属性名=project.homeVALUE =C:\\ Documents和Settings \\ bmcgeary \\工作区\\ New_Holiday_Editor/>  <属性名=build.home值=$ {} project.home /建造/>  <路径ID =文件类路径>
    <文件集DIR =C:/ jarfiles中>
      <包括姓名=*罐子。/>
    < /文件集>
  < /路径>  <! - 类路径转换为清单中的任务使用平面列表/串 - >
  < pathconvert财产=文件类路径pathsep =>
    <路径REFID =文件类路径/>
    < flattenmapper />
  < / pathconvert>  <清单文件=MANIFEST.MF>
    <属性名=内置到VALUE =$ {} manifest.built.by/>
    <属性名=创建,通过价值=$ {} manifest.created.by/>
    <属性名=主类值=$ {} manifest.main.class/>
    <属性名=实施-版本值=$ {} version.number -b $ {} build.number/>
    <属性名=类路径值=$ {文件类路径}/>
  < /清单>  <目标名称=编译>
    < javac的SRCDIR =。 />
  < /目标与GT;  <目标名称=compileProject描述=编译工程类>
    <回声>编译工程类< /回声>
    <javac的SRCDIR =SRCDESTDIR =>
      <&类路径GT;
    <路径REFID =文件类路径/>
      < /类路径>
    < / javac的>
  < /目标与GT;  <目标名称=罐子取决于=compileProject>
    <罐子jar文件=myJar.jar
     BASEDIR =。
     索引=真
     清单=MANIFEST.MF/>
  < /目标与GT;
< /项目>


解决方案

列出的类路径的相对位置的文件(罐)(罐的简单的名称,例如),然后将这些瓶子在同一目录作为小程序。
您使用的浏览器小程序?或用appletviewer中?
如果是用的浏览器,请尝试归档属性设置为 yourapplet.jar,ojdbc6.jar

和粘贴已生成清单,则可能是它的东西是错误的。

I have wrote a java applet which is pretty simple. It connects to a oracle database upon clicking a button. It works fine, it connects when I run it using Eclipse.

However, when I use ant to create the jar file I don't know how to include the ojdbc6.jar as a classpath. How would I do this?

Here is my ant build file. My external 3rd party Jar files that I need are in C:\JarFiles.

<project default="jar">
  <property name="build" value="build"/>
  <property name="java.home" value="C:\Program Files/Java/jdk1.6.0_10" />
  <property name="project.home" value="C:\Documents and Settings\bmcgeary\workspace\New_Holiday_Editor" />

  <property name="build.home" value="${project.home}/build" />

  <path id="files-classpath">  
    <fileset dir="c:/JarFiles" >  
      <include name="*.jar"/>  
    </fileset>  
  </path>  

  <!-- convert classpath to a flat list/string for use in manifest task -->
  <pathconvert property="files-classpath" pathsep=" ">
    <path refid="files-classpath" />
    <flattenmapper />
  </pathconvert>

  <manifest file="MANIFEST.MF">
    <attribute name="Built-By" value="${manifest.built.by}"/>
    <attribute name="Created-By" value="${manifest.created.by}"/>
    <attribute name="Main-Class" value="${manifest.main.class}"/>
    <attribute name="Implementation-Version" value="${version.number}-b${build.number}"/>   
    <attribute name="Class-Path" value="${files-classpath}" />
  </manifest>

  <target name="compile">
    <javac srcdir="." />
  </target>

  <target name="compileProject" description="compiles project Classes">  
    <echo>compiling the project classes</echo>  
    <javac srcdir="src" destdir=".">  
      <classpath>  
    <path refid="files-classpath" />  
      </classpath>  
    </javac>  
  </target> 

  <target name="jar" depends="compileProject" >
    <jar jarfile="myJar.jar"
     basedir="."
     index="true"
     manifest="MANIFEST.MF" />
  </target>


</project>

解决方案

List the files (jars) in the classpath as relative locations (simply the name of the jar, for example), and then place those jars in the same directory as the applet. Are you using the applet in browser? Or with appletviewer? If it is with browser, try setting the archive property to yourapplet.jar,ojdbc6.jar

And paste the manifest that has been generated, there might be something wrong with it.

这篇关于如何建立,需要一个外部罐子,用蚂蚁的小程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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