尽管显而易见,罐子找不到主要的课程

时间:2023-01-13 12:59:53

I am attempting to put my Java applet into a .Jar so I can sign it, as currently it works locally but throws access denied exceptions when I attempt to run it remotely (it reads other files in the directory).

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

I created the manifest file correctly when creating the jar and checked it:

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

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

netApp was an applet and runs fine, and it does contain a main method:

netApp是一个applet并且运行正常,它确实包含一个main方法:

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(); }
}

I have tried everything when creating the jar including just doing a:

我在创建jar时尝试了一切,包括只做一个:

jar cfm app.jar Manifest.txt *.*

When I try and run the jar from windows explorer or by running:

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

java -jar app.jar

it fails. with the generic error:

它失败。与一般错误:

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

netApp.class is definitely in the Jar.

netApp.class肯定在Jar中。

Thanks in advance for your help.

在此先感谢您的帮助。

1 个解决方案

#1


0  

Given the error message, it looks like it´s got the manifest correctly, but not the class itself. Run jar tvf app.jar to have a look.

鉴于错误消息,它看起来像是正确的清单,而不是类本身。运行jar tvf app.jar来看看。

Your jar command looks a little off to me... shouldn´t it be

你的jar命令对我来说有点不对......不应该

jar cfm app.jar manifest.txt *.*

?

#1


0  

Given the error message, it looks like it´s got the manifest correctly, but not the class itself. Run jar tvf app.jar to have a look.

鉴于错误消息,它看起来像是正确的清单,而不是类本身。运行jar tvf app.jar来看看。

Your jar command looks a little off to me... shouldn´t it be

你的jar命令对我来说有点不对......不应该

jar cfm app.jar manifest.txt *.*

?