• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

javac linking to jar file

 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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

 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yep, thats it, thanks!
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic