Message-ID: <5M8LUj$VPk@newsmth.net>
Subject: 使用javax.media.Player后如何释放资源?
Date: Fri, 07 Feb 2014 02:19:58 +0000
From: bjhbycthc@newsmth.net-SPAM.no (流水)
Path: 74.82.202.154!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!i2pn2.pugleaf.net!archive.newsdeef.eu!mbox2nntp-cn.bbs.comp.network.programming.20141003.mbox.gz!border1.nntp.dca3.giganews.com!backlog4.nntp.dca3.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!newsgate.cuhk.edu.hk!news.neu.edu.cn!news.newsmth.net!NEWSMTH
Newsgroups: cn.bbs.comp.network.programming
Organization: 水木社区
Mime-Version: 1.0
Content-Type: text/plain; charset="gb2312"
Content-Transfer-Encoding: 8bit
X-Filename: NetPRG/O/M.1391739597.K0
Lines: 28
X-Original-Bytes: 1550
Xref: 74.82.202.154 cn.bbs.comp.network.programming:13403

在eclipse上使用如下很简单的代码播放任意一首歌,但是播放完了之后,内存中javaw.exe一直存在,eclipse控制台的停止按钮也一直为红色。我不知怎么在内存中消除javaw.exe,非常感谢!
  
import java.io.File;    
import java.io.IOException;    
    
import javax.media.CannotRealizeException;    
import javax.media.Manager;    
import javax.media.NoPlayerException;    
import javax.media.Player;
    
public class MyPlayer {    
     private static String path = "1.mp3";    
    
     public static void main(String[] args) {    
         File f1 = new File(path);    
         try {    
             Player player = Manager.createRealizedPlayer(f1.toURI().toURL());    
             player.prefetch();    
             player.start();    
         } catch (CannotRealizeException ex) {    
         } catch (NoPlayerException ex) {    
         } catch (IOException ex) {    
         }    
     }    
} 

--

※ 来源:·水木社区 http://www.newsmth.net·[FROM: 115.32.2.*]