简单 Java 应用程序中的错误
只是玩弄java试图学习它等等。
这是我到目前为止使用HtmlUnit的代码。
package hsspider;
import com.gargoylesoftware.htmlunit.WebClient;
/**
* @author
*/
public class Main {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
System.out.println("starting ");
Spider spider = new Spider();
spider.Test();
}
}
package hsspider;
import com.gargoylesoftware.htmlunit.WebClient;
import com.gargoylesoftware.htmlunit.html.HtmlPage;
/**
* @author
*/
public class Spider {
public void Test() throws Exception
{
final WebClient webClient = new WebClient();
final HtmlPage page = webClient.getPage("http://www.google.com");
System.out.println(page.getTitleText());
}
}
我正在使用 Netbeans。
我似乎无法弄清楚问题是什么,为什么它不能编译?
错误:
C:\Users\mrblah\.netbeans\6.8\var\cache\executor-snippets\run.xml:45:
Cancelled by user.
BUILD FAILED (total time: 0 seconds)
xml 中的行是:
<translate-classpath classpath="${classpath}" targetProperty="classpath-translated" />
Just playing around with java trying to learn it etc.
Here is my code so far, using HtmlUnit.
package hsspider;
import com.gargoylesoftware.htmlunit.WebClient;
/**
* @author
*/
public class Main {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
System.out.println("starting ");
Spider spider = new Spider();
spider.Test();
}
}
package hsspider;
import com.gargoylesoftware.htmlunit.WebClient;
import com.gargoylesoftware.htmlunit.html.HtmlPage;
/**
* @author
*/
public class Spider {
public void Test() throws Exception
{
final WebClient webClient = new WebClient();
final HtmlPage page = webClient.getPage("http://www.google.com");
System.out.println(page.getTitleText());
}
}
I am using Netbeans.
I can't seem to figure out what the problem is, why doesn't it compile?
The error:
C:\Users\mrblah\.netbeans\6.8\var\cache\executor-snippets\run.xml:45:
Cancelled by user.
BUILD FAILED (total time: 0 seconds)
The row in the xml is:
<translate-classpath classpath="${classpath}" targetProperty="classpath-translated" />
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
测试声明抛出异常。如果您将“抛出异常”添加到您的 main 方法中,它应该可以编译。例如:
Test is declared to throw Exception. If you add "throws Exception" to your main method it should compile. For example:
史蒂夫说的是正确的。但
Test
的大写字符可能存在一些问题。方法始终以小写字符开头。所以test
会更好。What Steve said is correct. But maybe there are some problems with the uppercase character of
Test
. A method always starts with a lower case character. Sotest
would be better.取消选中 Netbeans 7.1.2 中“属性”选项卡的“保存时编译”选项为我解决了类似的错误消息。
Unchecking the "Compile on Save" option of the "Properties" tab in Netbeans 7.1.2 resolved a similar error message for me.