JSOUP问题-无法找到或加载主类 [英] JSOUP Issues - Could not find or load main Class

查看:93
本文介绍了JSOUP问题-无法找到或加载主类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法在计算机上运行JSOUP.我已经从网络上下载了JSOUP1.8.3,并尝试了很多方法来使它继续下去.

I'm having an issue getting JSOUP going on my computer. I've downloaded JSOUP1.8.3 from the web and have tried many things to get it going.

我正在Windows 7上运行JRE7.我觉得我可以使用命令行来了解更多信息,所以我坚持了这一点.我在NotePad ++中键入程序,然后使用命令行运行它们.

I'm running JRE7 on Windows 7. I feel like I learn more using the command line so I've stuck with that. I type my programs in NotePad++ and use the command line to run them.

这是我尝试过的: 1)将CLASSPATH设置为指向我的JSOUP.jar文件.这可以与编译一起使用,但是当我尝试运行文件时,出现错误找不到或加载主类" 2)解压缩JAR文件,将JSOUP文件夹添加到ORG文件夹,然后重新编译.这没有用,并导致了错误(无法记住该错误,但是我的计算机不喜欢它.) 3)使用-cp开关.同样,这适用于编译,但不适用于运行.

Here's what I've tried: 1)setting CLASSPATH to point to my JSOUP.jar file. This works with compiling but when I try to run my file I get the error "Could not find or load main Class" 2)unpacking the JAR file, adding the JSOUP folder to the ORG folder then recompiling. This didn't work and caused an error (Cant remember the error but my computer didn't like it.) 3)using the -cp switch. Again this works for compiling but not for running.

要编译:

javac -cp c:\js\jsoup.jar WS1.java

这没有问题.当我尝试使用

This works with no issues. When I try to run it with

java -cp c:\js\jsoup.jar WS1

我收到错误消息找不到或加载主类."

I get the error "Could not find or load main class."

我不确定您还需要其他哪些信息来帮助我解决此问题.我已经为此工作了几个小时,只是想不通.让我知道是否需要更多信息-谢谢-肯尼迪(JF)

I'm not sure what other info you need to help me with this issue. I've been working on this for hours and just can't figure it out. Let me know if you need more info - Thanks - JF

推荐答案

感谢Dariusz解决了该问题.为了通过命令行使用JAR文件,您有两个选择:

Thanks to Dariusz this problem is resolved. In order to use a JAR file through the command line you have two options:

1)使用-cp开关.例如,要编译:

1)use the -cp switch. For example, to compile:

javac -cp c:\yourFolder\yourJarFile.jar yourSourceCode.java

然后运行您的Java程序:

Then to run your java program:

java -cp c:\yourFolder\yourJarFile.jar;. yourClassFile

在这种情况下,

yourJarFile是jsoup.jar

yourJarFile in this case was jsoup.jar

yourClassFile是WS1和

yourClassFile was WS1 and

您的SourceCode是WS1.java

yourSourceCode was WS1.java

2)您的第二个选择是将以下内容创建/添加到类路径系统变量中:

2) Your second option is to create/add the following to your classpath system variable:

c:\yourFolder\yourJarFile.jar;.;%classpath%

选项2是我所使用的.这使我不必在每次编译/运行Java代码时都使用-cp标志.

Option 2 is the one I went with. This allows me to not have to use the -cp flag everytime I compile/run my java code.

阻碍我前进的主要因素是句号或圆点.我知道我需要添加当前目录,但不知道如何.因此,请确保您添加了添加的JAR文件的位置以及当前目录的句点/点,这样您就可以顺利进行了.

The main thing that was holding me up here was the period or dot. I knew that I needed to add the current directory but didn't know how. So, make sure that you add the location of your added JAR file and the period/dot for the current directory and you'll be good to go.

谢谢大家的帮助!!! JF

THANK YOU ALL FOR YOUR HELP!!! JF

这篇关于JSOUP问题-无法找到或加载主类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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