aspose file tools
The moose likes Beginning Java and the fly likes javac linking to jar file Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "javac linking to jar file" Watch "javac linking to jar file" New topic
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!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: javac linking to jar file
 
Similar Threads
controller not getting call on start up
[META/cxf/cxf.xml] cannot be opened because it does not exist
NoClassDefFoundError: org/springframework/context/ApplicationListener
Need Servlets 4a Help
Quick refresher.....