繁体   English   中英

尽管明显,罐子找不到主类

[英]jar could not find main class, despite manifest

我试图将Java小程序放入.Jar,以便对其进行签名,因为当前它在本地运行,但是在尝试远程运行它时会抛出拒绝访问的异常(它会读取目录中的其他文件)。

我在创建jar时正确创建了清单文件并进行了检查:

Manifest-Version: 1.0
Created-By: 1.6.0_25 (Sun Microsystems Inc.)
Main-Class: netApp

netApp是一个applet,运行良好,它确实包含一个主要方法:

import java.awt.*;

import jv.geom.PgElementSet;
import jv.object.PsMainFrame;
import jv.project.PvDisplayIf;
import jv.viewer.PvViewer;
import jv.loader.PgJvxLoader;
import jv.project.PgJvxSrc;
import jv.project.PjProject;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.FileReader;
import jv.loader.PjImportModel;
import jv.project.PjProject;
import jv.project.PgGeometry;
import jv.viewer.PvViewer;


import jv.object.PsDebug;

import java.applet.Applet;

public class netApp extends Applet {
    public      Frame               m_frame         = null;
    protected   PvViewer            m_viewer;
    protected   PgGeometry          m_geom;
    protected   netAppProj          myModel;

    public void init() {
        // Create viewer for viewing 3d geometries. References to the applet and frame
        // allow JavaView to decide whether program runs as applet or standalone application,
        // and, in the later case, it allows to use the frame as parent frame.
        m_viewer = new PvViewer(this, m_frame);
        //myModel.addActionListener();
        // Create and load a project which contains the user application. Putting code
        // in a JavaView project allows to reuse the project in other applications.
        myModel = new netAppProj();
        m_viewer.addProject(myModel);
        //myModel.start();
        m_viewer.selectProject(myModel);

        setLayout(new BorderLayout());
        // Get 3d display from viewer and add it to applet
        add((Component)m_viewer.getDisplay(), BorderLayout.CENTER);
        add(m_viewer.getPanel(PvViewer.PROJECT), BorderLayout.EAST);
        m_viewer.showPanel(PvViewer.MATERIAL);


        // Get default display from viewer
        PvDisplayIf disp = m_viewer.getDisplay();
        // Register geometry in display, and make it active.
        // For more advanced applications it is advisable to create a separate project
        // and register geometries in the project via project.addGeometry(geom) calls.
        disp.addGeometry(m_geom);
        disp.selectGeometry(m_geom);
        //disp.addPickListener(myModel);
        /*until here */


    }

    /**
     * Standalone application support. The main() method acts as the applet's
     * entry point when it is run as a standalone application. It is ignored
     * if the applet is run from within an HTML page.
     */
    public static void main(String args[]) {
        netApp app  = new netApp();
        // Create toplevel window of application containing the applet
        Frame frame = new jv.object.PsMainFrame(app, args);
        frame.pack();
        // Store the variable frame inside the applet to indicate
        // that this applet runs as application.
        app.m_frame = frame;
        app.init();
        // In application mode, explicitly call the applet.start() method.
        app.start();
        // Set size of frame when running as application.
        netAppProj myModel = new netAppProj();
        frame.setSize(640, 550);        frame.setBounds(new Rectangle(420, 5, 640, 550));

        frame.setVisible(true);
    }
    /** Print info while initializing applet and viewer. */
    public void paint(Graphics g) {
        g.setColor(Color.blue);
        //g.drawString("Loading Geometry Viewer Version: "+PsConfig.getVersion(), 20, 40);
        g.drawString("Loading Projects .....", 20, 60);
    }

    /**
     * Does clean-up when applet is destroyed by the browser.
     * Here we just close and dispose all our control windows.
     */
    public void destroy()   { m_viewer.destroy(); }

    /** Start viewer, e.g. start animation if requested */
    public void start()     { m_viewer.start(); }

    /** Stop viewer, e.g. stop animation if requested */
    public void stop()      { m_viewer.stop(); }
}

创建jar时,我已经尝试了所有方法,包括只做一次:

jar cfm app.jar Manifest.txt *.*

当我尝试从Windows资源管理器或通过运行运行jar时:

java -jar app.jar

它失败。 与一般错误:

Could not find the main class: netApp. Program will exit.

netApp.class肯定在Jar中。

在此先感谢您的帮助。

给定错误消息,看起来正确地获得了清单,但类本身没有。 运行jar tvf app.jar看看。

您的jar命令对我来说看起来有点...应该不是

jar cfm app.jar manifest.txt *.*

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM