无法导入javax.media.*; (包不存在)为什么这样说? [英] unable to import javax.media.*; (package does not exist) Why does it say so?

查看:607
本文介绍了无法导入javax.media.*; (包不存在)为什么这样说?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经下载了 JMF MP3 PLUGIN 来播放mp3文件. .下载后,将mp3plugin.jar放入netbeans的项目库中.

I have downloaded JMF MP3 PLUGIN to play mp3 files. After downloading i place mp3plugin.jar into the project library of netbeans.

然后我从以下代码行开始代码: import javax.media.*;

Then i start the code with the line : import javax.media.*;

但是有一个与此语句相对应的错误,该错误表明软件包javax.media不存在.为什么会出现此错误?我尝试搜索它,但没有找到解决方案.请帮助我. 我也将C:\Program Files\Java\jdk1.7.0\jre\lib\ext\mp3plugin.jar放在了classpath变量中.

But there is an error corresponding to this statement which says package javax.media does not exist. Why do i get this error ? I have tried searching about it but haven't found the solution. Please help me in this. I have also placed C:\Program Files\Java\jdk1.7.0\jre\lib\ext\mp3plugin.jar in the classpath variable.

推荐答案

在编译时不必导入服务提供者接口.只需将其添加到运行时类路径中,它将能够播放mp3以及其(默认)wave/pcm/midi文件.

It is not necessary to import a Service Provider Interface at compile time. Simply add it to the run-time class-path and it will be able to play mp3's as well as its (default) wave/pcm/midi files.

我将[mp3plugin.jar][1]这种方式用于DukeBox,这是M3U样式播放列表的小播放器,它工作得很好.请注意,它将添加使用JavaSound(javax.sound.sampled)读取MP3格式的功能.如果您打算使用JMF播放器播放MP3(这是不必要的,我不建议这样做),则需要在编译和添加两个主JMF jar的同时添加JMF jar.运行时.

I use the [mp3plugin.jar][1] this way for DukeBox, a little player for M3U style playlists, and it works just fine. Note that it will add the ability to read MP3 format using JavaSound (javax.sound.sampled). If you intend playing the MP3 using the JMF player (which is unnecessary, and I do not recommend), you'll need to add the main JMF jar at both compile & run-time.

以下是使用JavaSound播放声音的示例代码.不要被代码的长度所困扰,其中大部分是注释和解释.

Here is an example code for playing sounds using JavaSound. Don't be put off by the length of the code, most of that is comments and explanation.

它将编译而无需导入JMF的任何.如果mp3plugin.jar运行时类路径上,则它应该能够播放MP3.

It will compile without importing any of JMF. If the mp3plugin.jar is on the run-time class-path, it should be capable of playing MP3s.

这篇关于无法导入javax.media.*; (包不存在)为什么这样说?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆