Blue
Red
Green
Orange
Voilet
Slate
Dark

java.net.MalformedURLException问题(100分)

  • 主题发起人 sillyjohn
  • 开始时间
S

sillyjohn

Unregistered / Unconfirmed
GUEST, unregistred user!
我在编译一个例子时出现以下错误:
play.java:94: Exception java.net.MalformedURLException must be caught,
or it must be declared in the throws clause of this method.
getAppletContext().showDocument(
new URL(getCodeBase(),getParameter("source")));
^
play.java:96: Class MalformedURLEXception not found.
catch(MalformedURLEXception e){
^
Note: play.java uses or overrides a deprecated API.
Recompile with "-deprecation" for details.
原代码如下:
public boolean action(Event evt,Object arg){
if (evt.target instanceof Button){
try{
getAppletContext().showDocument(
new URL(getCodeBase(),getParameter("source")));
}
catch(MalformedURLEXception e){
e.parintStackTrace();}
return(true);
}
return(false);
}

我想问问
1)
Class MalformedURLEXception not found.是因为没IMPORT还是我的环境中没有?
2)如何解决?
3)play.java uses or overrides a deprecated API.
Recompile with "-deprecation" for details.
什么意思?
初学JAVA。问题多多。100分是少了点,但要留待以后问*—)
谢谢!
 
L

LIUniverse

Unregistered / Unconfirmed
GUEST, unregistred user!
应该用:
import java.net.*;
使用格式为
URL url = null;
try
{ url = new URL(...)
...
}
catch (MalformedURLException e)
{...}
-deprecation 说明有某个方法在play.java中被什么新方法给取代了,虽然可以
用,但是还是给出一个警告给你知道。你可以在project -> property中找到应该项
但你还是需要到HELP中找到替代的方法。
 
S

sillyjohn

Unregistered / Unconfirmed
GUEST, unregistred user!
getAppletContext().showDocument(
new URL(getCodeBase(),getParameter("source")));

url=nrl URL(...)其实等效。
我也已经import 了java.net.*
谢谢!
不过想问问那有help 文件下载!我不知道在那里!谢谢!
我用的是Jpadpro.
 
L

LIUniverse

Unregistered / Unconfirmed
GUEST, unregistred user!
这个问题我就真的回答不了了。因为我用的JBUILDER 3.0,它的HELP的确是非常的详
尽,就是太慢了……
既然你的开发软件已经指明了问题,你先试试把那个选项打开吧,也许它会给有些有
用的提示。我的JBUILDER就是要我到它的DOCUMENTATION里去找答案。
 
S

sillyjohn

Unregistered / Unconfirmed
GUEST, unregistred user!
Thanks!
我也想用Jbuilder,可惜载不下来,也没去找盗版,觉的Jpadpro还可以,
不过他没有任何帮助文件,连编译环境也的自己加载,不过还可以。
我已经下载了一个help,相信我会解决这个问题的。也看看别人的回答。
以后在讨教!
 
S

sillyjohn

Unregistered / Unconfirmed
GUEST, unregistred user!
接受答案了.
 

Similar threads

S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
I
回复
0
查看
1K
import
I
I
回复
0
查看
3K
import
I
I
回复
0
查看
2K
import
I
顶部 底部