LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial 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
 
Search this Thread
Old 12-29-2009, 03:52 AM   #1
raequin
LQ Newbie
 
Registered: Dec 2009
Posts: 2

Rep: Reputation: 0
Yet another java classpath question --- java.lang.NoClassDefFoundError Jama


Hi, all. I have been searching the webs for instructions on how to get my java code to run, but I still get the following error:

Exception in thread "main" java.lang.NoClassDefFoundError: Jama/Matrix

The code compiles fine, but the preceeding error is thrown when I go to run it. Here are the details:

I have downloaded Jama-1.0.2.jar to my desktop (/home/matt/Desktop/). My source and class files are in another directory. I'll paste the source code below, since it's very small; just a simple application to try and get this issue ironed out.

CPTesting.java:

Code:
public class CPTesting {
    public static void main(String[] args) {
	NGN testNew = new NGN(4, 5);
    }
}
NGN.java:

Code:
import Jama.Matrix;

class NGN {
    Matrix f_k, f_k1, deltaF;
    Matrix theta_k, theta_k1, hTheta;
    Matrix t_k, t_k1, hT;
    Matrix hTilde;
    Matrix JTilde_k, JTilde_k1;
    Matrix fHat_t_k, fHat_t_k1;
    Matrix JHat_k, JHat_k1;

    public NGN(int fs, int dof) {
	//	JHat_k1 = new Matrix(dof, fs);
	JHat_k1 = new Matrix(5, 6);
	//	JHat_k1 = JHat_k1.identity(dof, fs);
	JHat_k1.print(1, 1);
    }
}
I compile with the following commands:

Code:
javac CPTesting.java
and

Code:
javac NGN.java -cp /home/matt/Desktop/Jama\-1\.0\.2.jar
No errors, as I said. Then:

Code:
java CPTesting 
Exception in thread "main" java.lang.NoClassDefFoundError: Jama/Matrix
	at NGN.<init>(NGN.java:14)
	at CPTesting.main(CPTesting.java:3)
Caused by: java.lang.ClassNotFoundException: Jama.Matrix
	at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:319)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:264)
	at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:332)
	... 2 more
and

Code:
java CPTesting -cp /home/matt/Desktop/Jama\-1\.0\.2.jar
Exception in thread "main" java.lang.NoClassDefFoundError: Jama/Matrix
	at NGN.<init>(NGN.java:14)
	at CPTesting.main(CPTesting.java:3)
Caused by: java.lang.ClassNotFoundException: Jama.Matrix
	at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:319)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:264)
	at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:332)
	... 2 more
So ... I'm stumped. Please elucidate for me.

Thanks!
 
Old 12-29-2009, 01:04 PM   #2
raequin
LQ Newbie
 
Registered: Dec 2009
Posts: 2

Original Poster
Rep: Reputation: 0
solved

A member of the ubuntu forum showed me a fix. I'm going to post it here for posterity.

Quote:
I think the problem you're seeing here is because you don't have the current directory in your classpath. It is finding your jama classes okay, b/c you specified that path, but it then goes to load NGN and it doesn't know where the classes are.

Simple fix, change your classpath to this and I think it will work...
Code:
java -cp /home/matt/Desktop/Jama\-1\.0\.2.jar:. CPTesting
 
1 members found this post helpful.
  


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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Java NoClassDefFoundError when using Jama jdwilder Programming 5 03-29-2008 05:23 AM
java.lang.NoClassDefFoundError robbbert Programming 6 07-16-2006 06:47 AM
Java: java.lang.NoClassDefFoundError: javaapplication8/Factorial chief_officer Programming 9 05-31-2006 03:28 PM
java exception: java.lang.NoClassDefFoundError kath Programming 12 05-11-2006 04:37 AM
java.lang.NoclassDefFoundError rlnd Programming 5 02-18-2006 04:54 AM


All times are GMT -5. The time now is 06:01 AM.

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 Google+: linuxquestions
Open Source Consulting | Domain Registration