LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
LinkBack Search this Thread
Old 03-25-2005, 03:04 PM   #1
dwight
LQ Newbie
 
Registered: Sep 2004
Location: Estonia
Distribution: Arch
Posts: 14

Rep: Reputation: 0
Adding java components


A few days ago I needed to use a extenal library for java, namely the Jakarta Commons math library. Unfortunately there were no istrucytions on how to install it. So I just unpacked it and got a jar file. Took some experimenting but I got eclipse to find the jar file and was able to use it. But if I run my program outside of eclipse I get an error:
Code:
Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: org/apache/commons/math/random/RandomDataImpl
So what do I need to do in order to be able to use this library outside of eclipse? Is there a directory where i have to put the libraries i use? Is there some PATH variable i need to set?
 
Old 03-25-2005, 03:14 PM   #2
saravkrish
Member
 
Registered: Mar 2004
Location: KY, USA
Distribution: Fedora Core 1
Posts: 190

Rep: Reputation: 30
Hi,

Put the jar file somewhere (say ~/libs/) and then do the following to run your program:

java -cp ~/libs/ <classname to run>

The -cp option takes a ":" separated list of dirs to look at for packages. There is also some environment variable you could set but I forgot the name. Its one of these:

JAVA_CLASSPATH
CLASSPATH

-Sarav
 
Old 03-25-2005, 03:23 PM   #3
dwight
LQ Newbie
 
Registered: Sep 2004
Location: Estonia
Distribution: Arch
Posts: 14

Original Poster
Rep: Reputation: 0
Thanks. It worked. Didn't move the library file, just used the cp option with the location of the jar file. Actually at first, with just the directory name, i got the same error, but when i added the name of the jar file and the directory of the class file i want to execute, it worked.
Thanks again
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding a java module to netbeans Setheck Linux - Software 0 03-28-2005 09:55 PM
adding java jdk to path snecklifter Linux - Newbie 4 11-01-2004 02:58 PM
Adding Java to my environment path? C8H10N4O2 Linux - Software 6 04-19-2004 01:38 PM
adding java plugin to mozilla linorg Linux - Newbie 1 01-01-2004 02:56 PM
Adding Java To Mozilla enk0d Linux - Software 5 05-12-2003 05:34 PM


All times are GMT -5. The time now is 02:50 PM.

Main Menu
 
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration