Solved

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

Posted on 2004-04-13
27
932 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
  • 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
 
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
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
triangle challenge 4 77
computer science syllabus 3 52
groupSum6 challenge 6 38
backtracking recursion  code 19 40
For customizing the look of your lightweight component and making it look opaque like it was made of plastic.  This tip assumes your component to be of rectangular shape and completely opaque.   (CODE)
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

757 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now