3

I'm a beginner in programming and I need to know how to import classes I got from the Internet to my text file. I downloaded JLayer for use in writing an MP3 player, but typing import javazoom.jl.player.Player; won't work, unlike the basic import statements like import javax.swing.JOptionPane;.

I read in some forums that I should move the JLayer library somewhere so that the import statement will work, but where exactly? My JLayer library is currently in my Downloads folder. What should I do?

syb0rg
  • 8,057
  • 9
  • 41
  • 81

2 Answers2

3

Put the JAR containing those classes in your CLASSPATH. You should know how to use the -classpath argument for both javac.exe and java.exe. Read the tools documentation.

duffymo
  • 305,152
  • 44
  • 369
  • 561
2

If you are using Eclipse or a similar IDE, select your project, then do:

File -> Properties -> Java Build Path -> Libraries (tab) -> Add External Jars

Use the finder to select your .jar file, and then Eclipse should do the rest for you.

Note: Eclipse will only reference the .jar file at its current location, it does not copy the .jar to your current project.


If you aren't using an IDE, duffymo's answer will work for you.

syb0rg
  • 8,057
  • 9
  • 41
  • 81