• Post Reply Bookmark Topic Watch Topic
  • New Topic

Adding third party JAR files to the JRE  RSS feed

 
Wilder Francisco
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.
 
Campbell Ritchie
Marshal
Posts: 56529
172
  • 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.
 
Rico Felix
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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!