aspose file tools*
The moose likes General Computing and the fly likes Problem with TextPad Classpath. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » General Computing
Bookmark "Problem with TextPad Classpath." Watch "Problem with TextPad Classpath." New topic
Author

Problem with TextPad Classpath.

Cameron ax
Greenhorn

Joined: Oct 04, 2012
Posts: 18
HI, everyone. I want to import Html parser to TextPad.

I have found one web page for teach how to do this.
http://htmlparser.sourceforge.net/javadoc/doc-files/using.html

I have read it, but, I have not idea what to do with Textpad.
I am using Windows base system, Jdk1.6.0, and Textpad. That is all I have.

Any Help Will Be Appreciated
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 13875
    
  10

Welcome to the Ranch.

TextPad is just a text editor. As far as I know, it doesn't know anything about Java by itself. So, there's no way to import Java code in any way.

When you compile your code that uses the HTML parser library, you must specify that you're using the library by using the -classpath (or -cp) option on the command line. So, the command to compile your source code would become something like:

C:\MyProject> javac -cp C:\SomeDir\HtmlParser.jar com\mypackage\MyProgram.java

And to run it, you'd specify:

C:\MyProject> java -cp C:\SomeDir\HtmlParser.jar;. com.mypackage.MyProgram

Note: The ";." in the second command is to include the current directory "." into the classpath, because that's where Java is going to look for your own class com.mypackage.MyProgram.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 36508
    
  16
Moving as would fit better in another forum. Not sure where.
Cameron ax
Greenhorn

Joined: Oct 04, 2012
Posts: 18
Jesper de Jong wrote:

C:\MyProject> javac -cp C:\SomeDir\HtmlParser.jar com\mypackage\MyProgram.java

And to run it, you'd specify:

C:\MyProject> java -cp C:\SomeDir\HtmlParser.jar;. com.mypackage.MyProgram

Note: The ";." in the second command is to include the current directory "." into the classpath, because that's where Java is going to look for your own class com.mypackage.MyProgram.


Thank you

and where should I post this command?

I tryed run this command in CMD,

set CLASSPATH=C:\lib\htmlparser.jar;C:\lib\htmllexer.jar;%CLASSPATH%
* I unziped lib folder, placed it in C Drive.

Somehow, it works. I guess it did change System Environment variable. I do not know if it is a appropriate way to do this.

I want to use html parser libraries to get the content between a html tag.

Is this a good way for doing this?
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 36508
    
  16
You should not set a CLASSPATH environment variable at all. If one already exists, it is probably a good idea to add a dot for current directory as its first entry.
What you are doing with the set command at the command line is setting a CLASSPATH for that particular command window. Which is a much better way to handle CLASSPATHs. You might do well to try . instead of %CLASSPATH% as its last entry, if there is no environment variable.
Cameron ax
Greenhorn

Joined: Oct 04, 2012
Posts: 18
Campbell Ritchie wrote:You should not set a CLASSPATH environment variable at all. If one already exists, it is probably a good idea to add a dot for current directory as its first entry.
What you are doing with the set command at the command line is setting a CLASSPATH for that particular command window. Which is a much better way to handle CLASSPATHs. You might do well to try . instead of %CLASSPATH% as its last entry, if there is no environment variable.


Thank you for the advice.
So, what I did in command line with set command did not change environment variable?

What should I do when I only want to set a claapath for one particular project?
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 36508
    
  16
To set the classpath for a particular project, do exactly what you did earlier. As I said, far better than using an environment variable. As far as I know, that sets the classpath for that particular command window, not the environment, but I might be mistaken.
If you want it for an application wrapped in a jar file, that is different. Look in the Java Tutorials under deployment; you will probably find this section most useful for this particular question.
Cameron ax
Greenhorn

Joined: Oct 04, 2012
Posts: 18
Campbell Ritchie wrote:To set the classpath for a particular project, do exactly what you did earlier. As I said, far better than using an environment variable. As far as I know, that sets the classpath for that particular command window, not the environment, but I might be mistaken.
If you want it for an application wrapped in a jar file, that is different. Look in the Java Tutorials under deployment; you will probably find this section most useful for this particular question.

Thank you so much.
That is what I have been looking for.

I think what I did earlier did change environment variable. I run that command once, after that, I find I can load htmparser.jar from everywhere.
Cameron ax
Greenhorn

Joined: Oct 04, 2012
Posts: 18
Jesper de Jong wrote:Welcome to the Ranch.

TextPad is just a text editor. As far as I know, it doesn't know anything about Java by itself. So, there's no way to import Java code in any way.

When you compile your code that uses the HTML parser library, you must specify that you're using the library by using the -classpath (or -cp) option on the command line. So, the command to compile your source code would become something like:

C:\MyProject> javac -cp C:\SomeDir\HtmlParser.jar com\mypackage\MyProgram.java

And to run it, you'd specify:

C:\MyProject> java -cp C:\SomeDir\HtmlParser.jar;. com.mypackage.MyProgram

Note: The ";." in the second command is to include the current directory "." into the classpath, because that's where Java is going to look for your own class com.mypackage.MyProgram.


Sorry to bother you once again.

Say I have unziped my htmlparser files on C:\lib, and I placed my program file on C:\myProgram,

So in DOS window, I run this command

javac -cp C:\lib\htmlparser.jar C:\myProgram\myProgram.java

it completed successfully

then I run java myProgram

It gave me NoClassDefFounndError.

But when I use set classpath method

It does work very well.

Why is that?
 
Consider Paul's rocket mass heater.
 
subject: Problem with TextPad Classpath.
 
Similar Threads
Have text editor need to add find funct
cannot find symbol
Can i use an DIE to help design my gui?
Please review my code
a really good Java editor