Solved

Exception in thread "main" java.lang.NoClassDefFoundError: AudioTest.java

Posted on 2004-04-13
27
962 Views
Last Modified: 2006-11-17
What could cause this? Here is the code


public class AudioTest
{
      public static void main(String[] args)
      {
            args =
                  new String[] {
                        "-c",  // concatenation mode
                        "-o",  // output file specified
                        "c:/test/test.wav", // output file
                        "c:/test/wav/kp1.wav", // input file 1
                        "c:/test/wav/kp2.wav", // input file 2
                        "c:/test/wav/kp3.wav", // input file 3
                        "c:/test/wav/kp4.wav" // input file 4
                        };

            AudioConcat.main(args);
      }
}

0
Comment
Question by:Drop_of_Rain
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 13
  • 7
  • 4
  • +1
27 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 10814374
You need to make sure current dir part of classpath

java -classpath .;%CLASSPATH% AudioTest
0
 

Author Comment

by:Drop_of_Rain
ID: 10814423
Could you explain that better please How do I do that, I haven't used the command line I use A Development Program named BlueJ it takes care of a lot of this
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 10814481
I don't know BlueJ, but you need to be able to load AudioTest and AudioConcat, so they must be on the classpath
0
Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

 
LVL 86

Expert Comment

by:CEHJ
ID: 10814510
This usually translates as the classes being part of your project with IDEs
0
 

Author Comment

by:Drop_of_Rain
ID: 10814588
I am very new to this I have never ran a program from the commandline where there is multiable classes involved like this. Even the books that I have used delt with only one at a time. I will be learning about that soon.

so they must be on the classpath

If you could give me a simple example maybe I could get it?
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 10814681
Are there any packages involved?
0
 

Author Comment

by:Drop_of_Rain
ID: 10814805
This was the error I got running this from the IDE

ClassNotFoundException
MixingAudioInputStream (in java.net.URL ClassLoader
0
 

Author Comment

by:Drop_of_Rain
ID: 10814810
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.io.IOException;
import java.net.URL;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;

import javax.sound.sampled.*;
import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.LineUnavailableException;
import javax.sound.sampled.LineListener;
import javax.sound.sampled.LineEvent;
import javax.sound.sampled.Mixer;
import javax.sound.sampled.SourceDataLine;
import javax.sound.sampled.DataLine;
import javax.sound.sampled.FloatControl;
import javax.sound.sampled.BooleanControl;

public class SequenceAudioInputStream extends AudioInputStream
{

      private static final boolean DEBUG = true;
      private List m_audioInputStreamList;
      private int m_nCurrentStream;

      public SequenceAudioInputStream(AudioFormat audioFormat, Collection audioInputStreams)
      {
            super(new ByteArrayInputStream(new byte[0]), audioFormat, AudioSystem.NOT_SPECIFIED);
            m_audioInputStreamList = new ArrayList(audioInputStreams);
            m_nCurrentStream = 0;
      }

      public void addAllAudioInputStream(ListOfFiles iterator) throws UnsupportedAudioFileException, IOException
      {
            while (iterator.hasMoreElements())
            {
                  addAudioInputStream(AudioSystem.getAudioInputStream((InputStream)iterator.nextElement()));
            }
      }
      
      private boolean addAudioInputStream(AudioInputStream audioStream)
      {
            if (DEBUG)
            {
                  out("SequenceAudioInputStream.addAudioInputStream(): called.");
            }

            if (!getFormat().matches(audioStream.getFormat()))
            {
                  if (DEBUG)
                  {
                        out("SequenceAudioInputStream.addAudioInputStream(): audio formats donot match, trying to convert.");
                  }

                  AudioInputStream asold = audioStream;
                  audioStream = AudioSystem.getAudioInputStream(getFormat(), asold);
                  if (audioStream == null)
                  {
                        out("### SequenceAudioInputStream.addAudioInputStream(): could notconvert.");
                        return false;
                  }

                  if (DEBUG)
                  {
                        out(" converted");
                  }
            }

            synchronized (m_audioInputStreamList)
            {
                  m_audioInputStreamList.add(audioStream);
                  m_audioInputStreamList.notifyAll();
            }

            if (DEBUG)
            {
                  out("SequenceAudioInputStream.addAudioInputStream(): enqueued " + audioStream);
            }
            return true;
      }

      private AudioInputStream getCurrentStream()
      {
            return (AudioInputStream) m_audioInputStreamList.get(m_nCurrentStream);
      }

      private boolean advanceStream()
      {
            m_nCurrentStream++;
            boolean bAnotherStreamAvailable = (m_nCurrentStream < m_audioInputStreamList.size());
            return bAnotherStreamAvailable;
      }

      public long getFrameLength()
      {
            long lLengthInFrames = 0;
            Iterator streamIterator = m_audioInputStreamList.iterator();
            while (streamIterator.hasNext())
            {
                  AudioInputStream stream = (AudioInputStream) streamIterator.next();
                  long lLength = stream.getFrameLength();
                  if (lLength == AudioSystem.NOT_SPECIFIED)
                  {
                        return AudioSystem.NOT_SPECIFIED;
                  }
                  else
                  {
                        lLengthInFrames += lLength;
                  }
            }
            return lLengthInFrames;
      }

      public int read() throws IOException
      {
            AudioInputStream stream = getCurrentStream();
            int nByte = stream.read();
            if (nByte == -1)
            {
                  /*
                  The end of the current stream has been signaled.
                  We try to advance to the next stream.
                  */
                  boolean bAnotherStreamAvailable = advanceStream();
                  if (bAnotherStreamAvailable)
                  {
                        /*
                        There is another stream. We recurse into this method
                        to read from it.
                        */
                        return read();
                  }
                  else
                  {
                        /*
                        No more data. We signal EOF.
                        */
                        return -1;
                  }
            }
            else
            {
                  /*
                  The most common case: We return the byte.
                  */
                  return nByte;
            }
      }

      public int read(byte[] abData, int nOffset, int nLength) throws IOException
      {
            AudioInputStream stream = getCurrentStream();
            int nBytesRead = stream.read(abData, nOffset, nLength);
            if (nBytesRead == -1)
            {
                  /*
                  The end of the current stream has been signaled.
                  We try to advance to the next stream.
                  */
                  boolean bAnotherStreamAvailable = advanceStream();
                  if (bAnotherStreamAvailable)
                  {
                        /*
                        There is another stream. We recurse into this method
                        to read from it.
                        */
                        return read(abData, nOffset, nLength);
                  }
                  else
                  {
                        /*
                        No more data. We signal EOF.
                        */
                        return -1;
                  }
            }
            else
            {
                  /*
                  The most common case: We return the length.
                  */
                  return nBytesRead;
            }
      }

      public long skip(long lLength) throws IOException
      {
            throw new IOException("skip() is not implemented in class SequenceInputStream.Mail < Matthias.Pfisterer @ web.de > if you need this feature.");
      }

      public int available() throws IOException
      {
            return getCurrentStream().available();
      }

      public void close() throws IOException
      {
            // TODO: should we close all streams in the list?
      }

      public void mark(int nReadLimit)
      {
            throw new RuntimeException("mark() is not implemented in class SequenceInputStream.Mail < Matthias.Pfisterer @ web.de > if you need this feature.");
      }

      public void reset() throws IOException
      {
            throw new IOException("reset() is not implemented in class SequenceInputStream.Mail < Matthias.Pfisterer @ web.de > if you need this feature.");
      }

      public boolean markSupported()
      {
            return false;
      }

      private static void out(String strMessage)
      {
            System.out.println(strMessage);
      }
}
0
 

Author Comment

by:Drop_of_Rain
ID: 10814831
It came from this this was highlighted    AudioConcat.main(args);



public class AudioTest
{
      public static void main(String[] args)
      {
            args =
                  new String[] {
                        "-c",  // concatenation mode
                        "-o",  // output file specified
                        "c:/test/test.wav", // output file
                        "c:/test/wav/kp1.wav", // input file 1
                        "c:/test/wav/kp2.wav", // input file 2
                        "c:/test/wav/kp3.wav", // input file 3
                        "c:/test/wav/kp4.wav" // input file 4
                        };

            AudioConcat.main(args);
      }
}
0
 
LVL 92

Assisted Solution

by:objects
objects earned 250 total points
ID: 10817840
your code could be simplified as:

public class AudioTest
{
     public static void main(String[] args)
     {
          AudioConcat.main(new String[] {
                    "-c",  // concatenation mode
                    "-o",  // output file specified
                    "c:/test/test.wav", // output file
                    "c:/test/wav/kp1.wav", // input file 1
                    "c:/test/wav/kp2.wav", // input file 2
                    "c:/test/wav/kp3.wav", // input file 3
                    "c:/test/wav/kp4.wav" // input file 4
                    });
     }
}
0
 

Author Comment

by:Drop_of_Rain
ID: 10820408
I have ran into package problems, with imported classes to make the program work. For this time I am going to let this go!
0
 
LVL 92

Expert Comment

by:objects
ID: 10820440
I'd suggest you put all your classes into a package.
0
 

Author Comment

by:Drop_of_Rain
ID: 10820533
The problem I had with that was this:   import org.tritonus.share.sampled.TConversionTool; in one of the files this in another:  import gnu.getopt.Getopt;. I got the jar files for these but am unsure of what to do. I know I have to create a package but how with these different names in import?
0
 
LVL 92

Expert Comment

by:objects
ID: 10820549
just put the jars in your JRE/JDK's respective "ext" directories.
0
 

Author Comment

by:Drop_of_Rain
ID: 10820576
What is the "ext" directories. I looked in the JDK one!
0
 

Author Comment

by:Drop_of_Rain
ID: 10820601
I HAVE THIS DIRECTORY j2sdk1.4.2
0
 
LVL 92

Assisted Solution

by:objects
objects earned 250 total points
ID: 10820699
it'll probably be:

j2sdk1.4.2/jre/lib/ext
0
 

Author Comment

by:Drop_of_Rain
ID: 10820727
Ok I got them in there now what, how do I handle:

import org.tritonus.share.sampled.TConversionTool; in one of the files this in another:  import gnu.getopt.Getopt;.  I know I have to create a package but how with these different names in import?
0
 
LVL 92

Expert Comment

by:objects
ID: 10820754
you just need to include those import statements in your code whenever you a class uses them.
0
 

Author Comment

by:Drop_of_Rain
ID: 10820777
I didn't mean that, now that those jar files are in the java directory the imports will work as they are named. Ok does the package need to starte from the root c:\\starting package folder\next folder\etc.?
0
 
LVL 92

Expert Comment

by:objects
ID: 10820862
When yusing packages you need to make sure that your directory structure mirrors your package structure and the the parent directory of your package is part of your classpath.

eg. if your package is au.com.objects, and your classes are stored in /project/classes/au/com/objects
then your classpath would nbeed to include /project/classes

http://www.mindprod.com/jgloss/classpath.html
0
 
LVL 9

Assisted Solution

by:mmuruganandam
mmuruganandam earned 250 total points
ID: 10821609
Keep the java-getopt-1.0.928981.jar and AudioConcat in the classpath to get it work.
0
 
LVL 9

Accepted Solution

by:
mmuruganandam earned 250 total points
ID: 10821923
Let say,
your java-getopt-1.0.928981.jar is in c:\test

your AudioConcat class file is at your working directory.


Then
javac -classpath .;c:\test\java-getopt-1.0.928981.jar AudioTest.java



Regards,
Muruga
0
 

Author Comment

by:Drop_of_Rain
ID: 10821981
I increased the points because this was such a long question.

Thanks everyone, it works and sounded fantastic.
Christopher
0
 

Author Comment

by:Drop_of_Rain
ID: 10822012
Thanks all you guys you are the greatest,
Christopher
0
 
LVL 9

Expert Comment

by:mmuruganandam
ID: 10822022
It is a great feeling to me that you have made it atlast.  All the best to you.
0
 
LVL 92

Expert Comment

by:objects
ID: 10828259
:)
0

Featured Post

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question