• Post Reply Bookmark Topic Watch Topic
  • New Topic

Classpath Question for commons-net-1.4.0  RSS feed

 
Danny Coopers
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I have downloaded the commons-net-1.4.0.jar archive as I need to be able to ftp to a remote host from within my java program. However upon trying to compile my source code I get the error message :

C:\FTPTesting\getDataFiles.java:1: package org.apache.commons.net.ftp does not exist
import org.apache.commons.net.ftp.*;

I presume this is related to me not setting the classpath correctly but I have little understanding of how this should be set and what exactly it does.

My specific questions are then.

1> Where do I copy the commons-net-1.4.0.jar file to on my C: drive, is there a specific loction where it needs to be ?.

2> My source code is in the Directory C:\FTPTesting and I am compling it from this directory also, how do i set the classpath so that it can always find the commons-net-1.4.0 library and what command do i use to set it up ?

Thanks

Danny
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are several ways to do this. A simple one would be to put the Net jar file into C:\FTPTesting, and compile and run with:

javac -classpath commons-net-1.4.0.jar *.java

java -classpath .;commons-net-1.4.0.jar getDataFiles
 
Eric McIntyre
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
RE: #2 - To make the classpath setting permanent, you need to modify your environment variables. Go into Control Panel, double-click System, click the Advanced tab, then the Environment Variables button. Edit the variable CLASSPATH (or add it if it doesn't exist) and append ";C:\path\to\commons-net-1.4.0.jar" to the current value.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!