简体   繁体   English

在命令提示符下运行jar文件。 Java无法在类路径中找到库

[英]Running jar file in command prompt. Java can't find libraries in classpath

EDIT: OK, I think I was being silly. 编辑:好的,我觉得我很傻。 What I really wanted to do was a runnable JAR. 我真正想做的是一个可运行的JAR。 I did and now it works. 我做了,现在它的工作原理。

So I'm trying to run a little program that interacts with some webpages. 所以我正在尝试运行一个与某些网页交互的小程序。 The program works fine when I launch it from Eclipse but when I export it to a jar file and try to run it from the command prompt I get this error message: 当我从Eclipse启动它时程序工作正常,但是当我将它导出到jar文件并尝试从命令提示符运行它时,我收到以下错误消息:

在此输入图像描述

What am I missing here? 我在这里错过了什么?

I'm assuming in Eclipse you've added the appropriate libraries to your build path. 我在Eclipse中假设您已经在构建路径中添加了适当的库。 When you run your program through eclipse, it automatically creates a java command including all your libraries in the classpath. 当您通过eclipse运行程序时,它会自动创建一个java命令,其中包括类路径中的所有库。

You need to do the same thing 你需要做同样的事情

java -cp /path/to/libs -jar muzictest.jar

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

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