• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Adding third party JAR files to the JRE

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello All!

Currently on the "File Handling" part of my java journey and came across a tutorial which showed how to copy a file with a single line of code as an alternative to using the core java classes. This involved using classes from the Apache Commons site, but so far I have not had any success in using it properly outside of Eclipse, which I'm staying away from for the time being (I'm using Notepad++).

I'm wanting to add the "Commons IO" library, but I'm guessing there's more to it than simply pasting it the jre/lib or jer/lib/ext folder, because so far my program keeps throwing the same error at compile time. I searched, but couldn't really find anything. Thank you in advance for your help and time.
 
Marshal
Posts: 70228
282
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Best way is to specify the path to that .jar as a -cp argument when you execute your app. -cp c:\myFolder\myJar.jar;. or something like that. Better info in our FAQ.
 
Wilder Francisco
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Compiled the code using -cp as suggested and it did so without errors. However, when I tried to run it I got a whole bunch of class not found errors.



Not sure what to try next.
 
Ranch Hand
Posts: 411
5
IntelliJ IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You also have to use -cp to run the application in order for the jvm to locate the dependencies
 
Wilder Francisco
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I actually tried prior to my previous post, and got the error below:
Error: Could not find or load main class CopyFile

This is the command I entered:

Compile:
javac -cp commons-io-2.4.jar CopyFile.java

Execute:
java -cp commons-io-2.4.jar CopyFile

Again, it compiled no problem, but It will not execute. Thanks.
 
Don't get me started about those stupid light bulbs.
    Bookmark Topic Watch Topic
  • New Topic