使用从jar文件导入的类从cmd运行Java程序 [英] run java program from cmd with class imports from jar files

查看:76
本文介绍了使用从jar文件导入的类从cmd运行Java程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿社区,我遇到了这个菜鸟问题,所以如果有人可以帮忙,那就太好了:)



所以就这样...



我正在尝试通过运行Java演示文件来测试斯坦福大学NLP解析器,该文件可从此处



我的问题可能出在进口商品上我在其他一些stackoverflow线程上尝试了解决方案,例如:
javac -cp jar / path / number / 1; jar / path / number / 2 ParserDemo.java

但是

java -cp jar / path / number / 1; jar / path / number / 2 ParserDemo

命令不起作用。



我也试图提取公共文件夹中的每个jar文件,但后来我得到了糟糕的类文件错误。我该如何解决?



P.S。请不要提出使用解析器在线版本的解决方案。



编辑:我正在使用Windows 8.1,以防万一有人需要了解

解决方案

由于它已作为注释发布,并且我不知道它是否可见以备将来参考,所以我将编写解决方案在这里,按照用户mlk的建议



我将Java命令固定为 java -cp。; jar / path / number / 1; jar / path / number / 2 ParserDemo ,它运行良好!



这是因为当前文件夹()未包含在类路径中,因此Java无法看到 ParserDemo.class 文件。


Hey community I have this rookie problem so if anyone could help that would be great :)

So here it goes...

I'm trying to test the stanford NLP parser by trying to run the java demo file which is included in the file you can download from here

My problem is probably on the imports of the classes included in the .jar files..I tried the solutions on some other stackoverflow threads such as doing
javac -cp "jar/path/number/1";"jar/path/number/2" ParserDemo.java
but the
java -cp "jar/path/number/1";"jar/path/number/2" ParserDemo
command didn't work.

I also tried to extract every jar file in a common folder but then I got the bad class file error..

So what's the move here? How can I solve this ?

P.S. please don't propose as a solution to use the online version of the parser.

EDIT: I'm using Windows 8.1 just in case somebody needs to know

解决方案

Since it was posted as a comment and I don't know if it would be visible for future reference I'm gonna write the solution down here as proposed by the user mlk

I fixed my java command to java -cp ".;jar/path/number/1";"jar/path/number/2" ParserDemo and it worked perfectly!

This is because the current folder (.) was not included in the classpath so Java could not see the ParserDemo.class file.

这篇关于使用从jar文件导入的类从cmd运行Java程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆