• 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
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

Classpath Question for commons-net-1.4.0

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Please enjoy this holographic presentation of our apocalyptic dilemma right after this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic