| Author |
javac linking to jar file
|
Brian R Wolf
Greenhorn
Joined: Jan 25, 2010
Posts: 18
|
|
Hi,
Im rusty w/java, I am using the htmlparser class library jar file --> htmlparser.jar
I listed the contents of htmlparser.jar like this:
C:\HTMLParser\HTMLParser\lib>jar tvf htmlparser.jar
0 Sat Sep 23 16:30:52 PDT 2006 META-INF/
514 Sat Sep 23 16:30:50 PDT 2006 META-INF/MANIFEST.MF
0 Sat Sep 23 14:37:04 PDT 2006 org/
.....
9598 Sat Sep 23 14:37:04 PDT 2006 org/htmlparser/Parser.class
==============================================================
I write this java code
import org.htmlparser;
class HelloWorldApp {
Parser parser = new Parser ("http://whatever");
public static void main(String[] args) {
System.out.println("Hello World!"); // Display the string.
}
}
=============================================================
I try to compile it:
C:\Documents and Settings\brian>javac -classpath c:\htmlparser\htmlparser\lib\htmlparser.jar HelloWorldApp.java
HelloWorldApp.java:6: package org does not exist
import org.htmlparser;
^
hmm...
Thanks Brian
|
 |
Mazer Lao Tzu
Ranch Hand
Joined: Jan 20, 2010
Posts: 35
|
|
The problem is in your import statement.
does not import org.htmlparser.Parser.
There are two common ways to import. One is to list every type you use, in which case you would have:
This way is often preferred.
The other is to import all the types in packages you use, in which case you would have:
This way is what you seem to have expected.
|
-- Mazer
|
 |
Brian R Wolf
Greenhorn
Joined: Jan 25, 2010
Posts: 18
|
|
|
yep, thats it, thanks!
|
 |
 |
|
|
subject: javac linking to jar file
|
|
|