• Post Reply Bookmark Topic Watch Topic
  • New Topic

javac linking to jar file  RSS feed

 
Brian R Wolf
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Brian R Wolf
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yep, thats it, thanks!
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!