簡體   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