Reputation: 103477
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" />
Upvotes: 0
Views: 2921
Reputation: 56
Unchecking the "Compile on Save" option of the "Properties" tab in Netbeans 7.1.2 resolved a similar error message for me.
Upvotes: 1
Reputation: 57274
Test is declared to throw Exception. If you add "throws Exception" to your main method it should compile. For example:
/**
* @param args the command line arguments
*/
public static void main(String[] args) throws Exception {
System.out.println("starting ");
Spider spider = new Spider();
spider.Test();
}
Upvotes: 5
Reputation: 68847
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. So test
would be better.
Upvotes: 1