Drop_of_Rain
asked on
Exception in thread "main" java.lang.NoClassDefFoundError: AudioTest.java
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);
}
}
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);
}
}
ASKER
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
I don't know BlueJ, but you need to be able to load AudioTest and AudioConcat, so they must be on the classpath
This usually translates as the classes being part of your project with IDEs
ASKER
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?
so they must be on the classpath
If you could give me a simple example maybe I could get it?
Are there any packages involved?
ASKER
This was the error I got running this from the IDE
ClassNotFoundException
MixingAudioInputStream (in java.net.URL ClassLoader
ClassNotFoundException
MixingAudioInputStream (in java.net.URL ClassLoader
ASKER
import java.io.ByteArrayInputStre am;
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.AudioF ormat;
import javax.sound.sampled.AudioI nputStream ;
import javax.sound.sampled.AudioS ystem;
import javax.sound.sampled.LineUn availableE xception;
import javax.sound.sampled.LineLi stener;
import javax.sound.sampled.LineEv ent;
import javax.sound.sampled.Mixer;
import javax.sound.sampled.Source DataLine;
import javax.sound.sampled.DataLi ne;
import javax.sound.sampled.FloatC ontrol;
import javax.sound.sampled.Boolea nControl;
public class SequenceAudioInputStream extends AudioInputStream
{
private static final boolean DEBUG = true;
private List m_audioInputStreamList;
private int m_nCurrentStream;
public SequenceAudioInputStream(A udioFormat audioFormat, Collection audioInputStreams)
{
super(new ByteArrayInputStream(new byte[0]), audioFormat, AudioSystem.NOT_SPECIFIED) ;
m_audioInputStreamList = new ArrayList(audioInputStream s);
m_nCurrentStream = 0;
}
public void addAllAudioInputStream(Lis tOfFiles iterator) throws UnsupportedAudioFileExcept ion, IOException
{
while (iterator.hasMoreElements( ))
{
addAudioInputStream(AudioS ystem.getA udioInputS tream((Inp utStream)i terator.ne xtElement( )));
}
}
private boolean addAudioInputStream(AudioI nputStream audioStream)
{
if (DEBUG)
{
out("SequenceAudioInputStr eam.addAud ioInputStr eam(): called.");
}
if (!getFormat().matches(audi oStream.ge tFormat()) )
{
if (DEBUG)
{
out("SequenceAudioInputStr eam.addAud ioInputStr eam(): audio formats donot match, trying to convert.");
}
AudioInputStream asold = audioStream;
audioStream = AudioSystem.getAudioInputS tream(getF ormat(), asold);
if (audioStream == null)
{
out("### SequenceAudioInputStream.a ddAudioInp utStream() : could notconvert.");
return false;
}
if (DEBUG)
{
out(" converted");
}
}
synchronized (m_audioInputStreamList)
{
m_audioInputStreamList.add (audioStre am);
m_audioInputStreamList.not ifyAll();
}
if (DEBUG)
{
out("SequenceAudioInputStr eam.addAud ioInputStr eam(): enqueued " + audioStream);
}
return true;
}
private AudioInputStream getCurrentStream()
{
return (AudioInputStream) m_audioInputStreamList.get (m_nCurren tStream);
}
private boolean advanceStream()
{
m_nCurrentStream++;
boolean bAnotherStreamAvailable = (m_nCurrentStream < m_audioInputStreamList.siz e());
return bAnotherStreamAvailable;
}
public long getFrameLength()
{
long lLengthInFrames = 0;
Iterator streamIterator = m_audioInputStreamList.ite rator();
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().availab le();
}
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(strMess age);
}
}
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.AudioF
import javax.sound.sampled.AudioI
import javax.sound.sampled.AudioS
import javax.sound.sampled.LineUn
import javax.sound.sampled.LineLi
import javax.sound.sampled.LineEv
import javax.sound.sampled.Mixer;
import javax.sound.sampled.Source
import javax.sound.sampled.DataLi
import javax.sound.sampled.FloatC
import javax.sound.sampled.Boolea
public class SequenceAudioInputStream extends AudioInputStream
{
private static final boolean DEBUG = true;
private List m_audioInputStreamList;
private int m_nCurrentStream;
public SequenceAudioInputStream(A
{
super(new ByteArrayInputStream(new byte[0]), audioFormat, AudioSystem.NOT_SPECIFIED)
m_audioInputStreamList = new ArrayList(audioInputStream
m_nCurrentStream = 0;
}
public void addAllAudioInputStream(Lis
{
while (iterator.hasMoreElements(
{
addAudioInputStream(AudioS
}
}
private boolean addAudioInputStream(AudioI
{
if (DEBUG)
{
out("SequenceAudioInputStr
}
if (!getFormat().matches(audi
{
if (DEBUG)
{
out("SequenceAudioInputStr
}
AudioInputStream asold = audioStream;
audioStream = AudioSystem.getAudioInputS
if (audioStream == null)
{
out("### SequenceAudioInputStream.a
return false;
}
if (DEBUG)
{
out(" converted");
}
}
synchronized (m_audioInputStreamList)
{
m_audioInputStreamList.add
m_audioInputStreamList.not
}
if (DEBUG)
{
out("SequenceAudioInputStr
}
return true;
}
private AudioInputStream getCurrentStream()
{
return (AudioInputStream) m_audioInputStreamList.get
}
private boolean advanceStream()
{
m_nCurrentStream++;
boolean bAnotherStreamAvailable = (m_nCurrentStream < m_audioInputStreamList.siz
return bAnotherStreamAvailable;
}
public long getFrameLength()
{
long lLengthInFrames = 0;
Iterator streamIterator = m_audioInputStreamList.ite
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().availab
}
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(strMess
}
}
ASKER
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);
}
}
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);
}
}
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I have ran into package problems, with imported classes to make the program work. For this time I am going to let this go!
I'd suggest you put all your classes into a package.
ASKER
The problem I had with that was this: import org.tritonus.share.sampled .TConversi onTool; 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?
just put the jars in your JRE/JDK's respective "ext" directories.
ASKER
What is the "ext" directories. I looked in the JDK one!
ASKER
I HAVE THIS DIRECTORY j2sdk1.4.2
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Ok I got them in there now what, how do I handle:
import org.tritonus.share.sampled .TConversi onTool; 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?
import org.tritonus.share.sampled
you just need to include those import statements in your code whenever you a class uses them.
ASKER
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.?
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/ob jects
then your classpath would nbeed to include /project/classes
http://www.mindprod.com/jgloss/classpath.html
eg. if your package is au.com.objects, and your classes are stored in /project/classes/au/com/ob
then your classpath would nbeed to include /project/classes
http://www.mindprod.com/jgloss/classpath.html
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I increased the points because this was such a long question.
Thanks everyone, it works and sounded fantastic.
Christopher
Thanks everyone, it works and sounded fantastic.
Christopher
ASKER
Thanks all you guys you are the greatest,
Christopher
Christopher
It is a great feeling to me that you have made it atlast. All the best to you.
:)
java -classpath .;%CLASSPATH% AudioTest