简体   繁体   English

尝试在Debian Jessie上执行.jar时出现Java异常错误

[英]Java Exceptions error when trying to execute .jar on Debian Jessie

A teacher of mine created a program on java around 2005, he has always used MacOS. 我的一位老师在2005年左右用Java创建了一个程序,他一直使用MacOS。 He sent the .jar to me and a classmate, both linux (me Debian 8 and him Ubuntu) and we can't execute the program because it returns a lot of exceptions. 他将.jar发送给我和一个同学(都是Linux(我是Debian 8,他是Ubuntu)),我们无法执行该程序,因为它返回了很多异常。

At first I thought it could have been because the program was too old but my teacher can run it in his 1 year old updated mac perfectly fine. 起初我以为可能是因为该程序太旧了,但是我的老师可以在他1岁的更新版Mac中很好地运行它。

Checked and Debian comes with OpenJDK as default. 选中,Debian默认带有OpenJDK。 Havent installed anything, is there anything I should be installing for it to run? Havent安装了任何东西,我应该安装任何东西才能使其运行吗?

PS: if I double click the .jar I can see the folders. PS:如果我双击.jar ,则可以看到文件夹。

The exceptions are: 例外是:

Exception in thread "main" java.lang.NoClassDefFoundError: org/jfree/chart/ChartPanel
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:803)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
    at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
    at java.lang.Class.getDeclaredMethods0(Native Method)
    at java.lang.Class.privateGetDeclaredMethods(Class.java:2625)
    at java.lang.Class.getMethod0(Class.java:2866)
    at java.lang.Class.getMethod(Class.java:1676)
    at sun.launcher.LauncherHelper.getMainMethod(LauncherHelper.java:494)
    at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:486)
Caused by: java.lang.ClassNotFoundException: org.jfree.chart.ChartPanel
    at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
    ... 18 more

I don't know anything about java so please if you can try to be as basic as you can. 我对Java一无所知,所以请您尽量尝试变得基本。 I am also new to Debian, so I really don't know if there's a package missing from the default installation. 我也是Debian的新手,所以我真的不知道默认安装中是否缺少软件包。

Edit: 编辑:

The MANIFEST.MF file is MANIFEST.MF文件是

Manifest-Version: 1.0
Ant-Version: Apache Ant 1.8.2
Created-By: 1.6.0_24-b07-334-10M3326 (Apple Inc.)
Class-Path: lib/Jama-1.0.2-ed.jar lib/jfreechart-1.0.6.jar lib/ant.jar
lib/jcommon-1.0.10.jar
X-COMMENT: Main-Class will be added automatically by build
Main-Class: com.cmcweb.electronicstructure.CompleteDOSPlotter

You have to download JFreeChart.jar libary ( http://www.java2s.com/Code/Jar/j/Downloadjfreechartjar.htm ) because your teacher didn't include external classes in his jar file. 您必须下载JFreeChart.jar库( http://www.java2s.com/Code/Jar/j/Downloadjfreechartjar.htm ),因为您的老师的jar文件中没有包含外部类。

Put JFreeChart.jar into /your_linux_path/jre/lib/ext folder and after that it should works. 将JFreeChart.jar放入/ your_linux_path / jre / lib / ext文件夹中,然后它应该可以工作了。

PS The same you have to do with Jama.jar and jcommon.jar PS与Jama.jar和jcommon.jar相同

Make sure you have all jars with the version from the manifest file downloaded in a lib directory. 确保所有lib版本的清单文件都下载到lib目录中。 Lib directory should be placed in the same directory as your jar, the names of dependency jars should be exactly the same as these from classpath in manifest. Lib目录应与jar放在同一目录中,依赖项jar的名称应与清单中来自classpath的名称完全相同。

So in your case, it may not work with the newest JFreeChart version. 因此,根据您的情况,它可能不适用于最新的JFreeChart版本。 You need to find and download version 1.0.6 您需要找到并下载1.0.6版

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

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