导入java库 [英] importing java libarary

查看:99
本文介绍了导入java库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开始学习一些编程语言.我学习了python,然后做了一点jython,现在想学习java.我读了一本基本书,但是在导入库方面还没有做任何事情.我想尝试使用Java的jsoup(因为我对python的beautifulsoup很熟悉,并认为这会使我的学习变得容易一些).

但是我尝试的示例一直失败( http://jsoup.org /cookbook/extracting-data/example-list-links ).我下载了jsoup,将其复制到library/java/extensions并尝试了上面的脚本,但是我不断得到:

Exception in thread "main" java.lang.IllegalArgumentException: usage: supply url to fetch
    at org.jsoup.helper.Validate.isTrue(Validate.java:45)
    at org.jsoup.examples.ListLinks.main(ListLinks.java:16)

起初,我认为库可能没有正确导入,或者我不得不做一些不同的事情才能在netbeans中获取它,但是当我查看我的项目时,我看到了一个库菜单,并且jsoup似乎在那里.

我在线尝试了其他一些脚本,但出现错误.我想我可能没有正确地导入它,但是任何人都可以帮助我确定问题所在(我是一个新手,我什至不知道该用什么谷歌找到答案).

提前谢谢!

解决方案

运行完美.

您列出(链接到)的代码将其作为程序要做的第一件事:

public static void main(String[] args) throws IOException {
    Validate.isTrue(args.length == 1, "usage: supply url to fetch");

它需要在命令行上将参数传递给程序才能运行(URL).正是在告诉您.

I am starting to learn a few programming languages. I learned python then did a bit of jython and now want to learn java. I read a basic book but haven't done anything with importing libraries yet. I wanted to try to play around with jsoup for java(since I am familiar with beautifulsoup for python and thought it would make learning a bit easier for me).

But the example I am trying keeps failing( http://jsoup.org/cookbook/extracting-data/example-list-links ). I downloaded jsoup, copied it to libraries/java/extentions and tried the above script but I keep getting:

Exception in thread "main" java.lang.IllegalArgumentException: usage: supply url to fetch
    at org.jsoup.helper.Validate.isTrue(Validate.java:45)
    at org.jsoup.examples.ListLinks.main(ListLinks.java:16)

At first I thought maybe the library wasn't imported right or I had to do something different to get it in netbeans but when I look at my project, I see a menu for libraries and jsoup seems to be there.

I tried a few other scripts online and am getting errors. I think I might not be importing it right, but can anyone help me identify the problem(I'm such a newbie I don't even know what to google to find the answer to this..)?

Thanks in advance!

解决方案

It's running perfectly.

The code you list (link to) has this as the first thing the program does:

public static void main(String[] args) throws IOException {
    Validate.isTrue(args.length == 1, "usage: supply url to fetch");

It requires an argument to be passed into the program on the command line for it to run (an URL). And it's telling you exactly that.

这篇关于导入java库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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