|
-
February 4th, 2007, 04:24 AM
#1
importing javazoom package
Hello Everyone, I'm writing an mp3 Player. I downloaded the JLayer 1.0. package but an error occurred while writing the following code. It has to do with the package :
-- cannot access javazoom.jl.player.Player;
class javazoom.jl.player.Player not found in stable package
Where did I go wrong ? I added JLayer library to my CLASSPATH ..
Code:
import javazoom.jl.player.Player;
import java.io.*;
public class MP3Player {
private Player player;
private InputStream is;
[..]
-
February 4th, 2007, 05:22 AM
#2
Re: importing javazoom package
Actually I'm trying to execute the MP3Player.java code .. but it is not working properly...
-
February 4th, 2007, 11:11 AM
#3
Re: importing javazoom package
Compiles fine here using JLayer 1.0.
Are you getting the error when compiling or when running the code?
Post up the full text of the error message.
Teachers open the door, but you must enter by yourself...
Chinese proverb.
Please use [CODE]...your code here...[/CODE] tags when posting code. If you get an error, please post the full error message and stack trace, if present.
-
February 4th, 2007, 01:28 PM
#4
Re: importing javazoom package
1- package : "com.informit.jlayer"
2- class name : MP3Player
3- Base class : java.lang.Object
I copied and pasted the code given in that link.
I added the library (JLayer 1.0) under the folder src
Error given now :
Could not find the main class.Program will exit!
java.lang.NoClassDefFoundError: com/informit/jlayer/MP3Player
-
February 4th, 2007, 02:50 PM
#5
Re: importing javazoom package
The root directory or jar file(s) of all the classes you're trying to run must be on the classpath, including the one with the main(..) method!
The value of a prototype is in the education it gives you, not in the code itself...
A. Cooper
Please use [CODE]...your code here...[/CODE] tags when posting code. If you get an error, please post the full error message and stack trace, if present.
-
February 5th, 2007, 09:48 AM
#6
Re: importing javazoom package
Excuse my ignorance with the ClassPath issue dlorde...
Start / Control Panel / Performance and Maintenance / System /
Advanced / Environment Variables / New
Variable name : classpath
Variable value : .;C:\Program Files\Java\jdk1.5.0\lib\jl1.0.jar
Am I on the right track now ? What am I supposed to do ?
-
February 5th, 2007, 11:50 AM
#7
Re: importing javazoom package
The system classpath is better left with the systemwide stuff that will always be needed, like the JDK libraries. It's not a particularly good idea to permanently append temporary project stuff onto it.
You can set the classpath on the command line:
java -classpath <classpath> mainClass
or
java -cp <classpath> projectMainClass
Where <classpath> would be the system classpath and the project classpath concatenated.
or you can set the classpath in advance:
REM append project classpath to system classpath
set classpath=%classpath%;projectclasspath
java projectMainClass
Setting the classpath in a command prompt window only sets it locally (for the duration of the command prompt window). Every Windows user application, including command prompt windows, is given a copy of all the system environment variables, so environment changes by user applications are local to the application.
See also Setting The Classpath.
Most regular programmers use an IDE, such as Eclipse, which make it easy to set the classpath for each project.
It is better to have an approximate answer to the right question than an exact answer to the wrong one...
J. Tukey
Please use [CODE]...your code here...[/CODE] tags when posting code. If you get an error, please post the full error message and stack trace, if present.
-
February 8th, 2007, 02:53 PM
#8
Re: importing javazoom package
I've written this command
java -classpath ".;C:\Program Files\Java\jdk1.5.0\lib\jl1.0.jar;C:\Documents and Settings\Nightmare\jbproject\com.informit.jlayer" com\informit\jlayer\MP3Player
and this is what I got :
Exception in thread "main" java.lang.NoClassDefFoundError: com\informit\jlayer\MP3Player
-
February 8th, 2007, 07:17 PM
#9
Re: importing javazoom package
Did you read the link I posted last time? It says:
"For a .jar or .zip file that contains .class files, the class path ends with the name of the .zip or .jar file.
For .class files in an unnamed package, the class path ends with the directory that contains the .class files.
For .class files in a named package,the class path ends with the directory that contains the "root" package (the first package in the full package name)."
They know enough who know how to learn...
J. Adams
Please use [CODE]...your code here...[/CODE] tags when posting code. If you get an error, please post the full error message and stack trace, if present.
-
February 10th, 2007, 02:55 AM
#10
Re: importing javazoom package
Thx a LOT dlorde !! It finally worked !
Still I have a prob with the Path to an mp3 song. For example, If I have a
song titled rockthenight.mp3 located on the Desktop , how can I make it
work ?
Code:
public static void main( String[] args )
{
if( args.length == 0 )
{
System.out.println( "Usage: MP3Player <filename>" );
System.exit( 0 );
}
MP3Player mp3Player = new MP3Player( args[ 0 ] );
mp3Player.play();
}
Listing 1 defines a main() method that accepts a single input argument, namely the path to an MP3 file, if it is not present then it displays the usage and closes.
Is this the right way to add the path ?
MP3Player mp3Player = new MP3Player("rockthenight.mp3") ?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|