我应如何包装了多个的.jar库的小程序? [英] How do I package up an applet with multiple .jar libraries?

查看:211
本文介绍了我应如何包装了多个的.jar库的小程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建从一个大规模的pre-现有项目(Vizster)Java小程序。我在Mac OS X

I'm creating a Java applet from a large scale pre-existing project (Vizster). I am using NetBeans 6.7.1 with JDK 1.5 on Mac OS X.

我试图运行小程序从它的.jar文件单独输出,但我这样做的时候,它说:小程序装的画面在Firefox底部,并没有什么Java控制台,但没有表演向上在窗口的小程序。我曾在Firefox previous不同的错误,这一点,包括错误,如appletNotLoaded:ClassDefNotFoundError,也有安全性错误,但从来没有在我的Java控制台的任何输出。这里是applet的HTML文件:

I am attempting to run the applet from it's single output .jar file, but when I do this, it says "applet loaded" at the bottom of screen in Firefox, and there is nothing in the java console, but nothing shows up in the window for the applet. I have had different errors in Firefox previous to this, including errors such as "appletNotLoaded:ClassDefNotFoundError" and also security errors, but there is never any output in my java console. Here is the html file for the applet:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
 <html>
  <head>
    <title></title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <applet codebase ="." code="zuve.ZuveApplet.class"
            archive="ZuveApplet.jar"
            height="1000" width="1000"/>
  </body>
</html>

在哪里zuve.ZuveApplet.class是我的主要方法所在,而ZuveApplet.jar是输出的jar文件的名称。这里是ZuveApplet.java,主要方法类:

Where zuve.ZuveApplet.class is where my main method is located, and "ZuveApplet.jar" is the name of the output jar file. Here is ZuveApplet.java, the main method class:

package zuve;

import vizster.Vizster;
import vizster.VizsterLib;
import java.applet.Applet;

 public class ZuveApplet extends Applet {
     public static final String DEFAULT_START_UID = "186297";

     @Override
     public void init() {
        new Vizster();
     }

    public static void main(String[] argv) {
        VizsterLib.setLookAndFeel();
        //String startUID = argv.length > 0 ? argv[0] : DEFAULT_START_UID;
        String startUID = DEFAULT_START_UID;
        String file = argv.length > 0 ? argv[0] : null;
        new Vizster(startUID, file);
    }
 }

小程序运转很好作为一个独立的(没有嵌入HTML),但我需要嵌入。在Vizster的对象是一个JFrame的延伸,所以我想我应该能够创建它的实例,并将其添加到一个applet。也许它会比这复杂得多?

The applet runs perfectly well as a standalone (not embedded in html), but I need to embed it. The "Vizster" object is an extension of a JFrame, so I figure I should just be able to create an instance of it and add it to an applet. Might it be much more complicated than this?

我是新来的Java小程序和一般的不幸。我已经看到了很多有关源代码树结构的论坛帖子的是一个问题,所以:

I'm new to java and applets in general unfortunately. I have seen a lot of forum posts about source tree structure being an issue, so:

1)是我使用多个包的一个问题?他们都在我的项目的src目录。

1)is it a problem that I am using multiple packages? They are all in the src directory of my project.

2)有什么我需要在我的Java主目录中放置?我知道很多人都有的类路径的问题,但我使用,我想照顾的一切对我来说是现代的IDE。

2)is there anything I need to be placing in my java home directory? I know a lot of people have classpath issues, but I am using a modern IDE which I thought took care of all that for me.

3)导入我的项目转换为NetBeans Java的Web应用程序项目的时候,我应该添加小程序,以项目为一个.jar,或者我应该补充,整个项目?

3)when importing my project into a NetBeans Java Web Application project, should I be adding the applet to the project as a .jar, or should I add the whole project?

4)原来,当我创造了这个小程序,我只是我的一些源文件和依赖一堆的.jar库,但是当我检查了输出的.jar,我看到的都是编译源文件。没有从库中的​​文件的痕迹。这是应该如何?我注意到,如果我从它包含文件夹的.jar移动的输出,它再也不能独立运行。我以为.jar文件都应该是自成一体,这是不是真的?有什么我应该知道作出的执行的罐子?

4)Originally when I had created this applet, I just had my few source files and a bunch of .jar libraries as dependencies, but when I inspected the output .jar, all I saw were the compiled source files. There was no trace of the files from the libraries. Is this how it should be? I noticed that if I moved the output .jar from its containing folder, it could no longer run standalone. I thought that .jars were supposed to be self contained, is this not true? Is there anything I should know about making an executable jar?

5)在一个侧面说明,并在HTML中的小应用程序标记表示的小应用程序的大小有小程序本身的大小完全一致?

5)on a side note, does the size of the applet denoted in the applet tags in the html have to exactly match the size of the applet itself?

对不起,巨大的岗位,以及令人难以置信的模糊的问题,我有一个团队中没有人知道小程序或Java(真正辉煌的我们,我知道)什么工作。任何形式的帮助或一般性建议,将真正帮助。

Sorry for the enormous post, and the incredibly vague problem, I am working with a team in which nobody knows anything about applets or Java (real brilliant of us, I know). Any sort of help or general suggestions would really help.

感谢您!

推荐答案

您可以在存档属性指定多个jar文件:

You can specify multiple jars in the archive attribute:

<applet codebase ="." code="zuve.ZuveApplet.class"
        archive="ZuveApplet.jar,thing.jar,anotherThing.jar"
        height="1000" width="1000"/>

一个JFrame的是一个顶级容器,所以您将无法将其添加到您的小程序。你可以有你的小程序创建的对象的实例,并让它打开自己的窗口。一个更灵活的方法是重构你的对象变成一个JPanel。作为一个JPanel,它可被添加到一个JApplet的,或以一个JFrame如果还希望以支持运行作为一个应用程序。

A JFrame is a top-level container, so you won't be able to add it to your applet. You can have your applet create an instance of your object and let it open its own window. A more flexible approach would be to refactor your object into a JPanel. As a JPanel, it can be added to a JApplet, or to a JFrame if you also want to support running it as an application.

另外看看 JNLP 因为这可以让您部署code作为一个applet或应用程序,还提供的API 用于印刷和本地文件访问。功能不可用简单的小程序。

Also take a look at JNLP as that lets you deploy your code as an applet or as an application and also provides APIs for printing and local file access. Functionality not available to simple applets.

这篇关于我应如何包装了多个的.jar库的小程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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