且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

JSOUP问题-无法找到或加载主类

更新时间:2023-11-20 10:08:04

感谢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