当前位置: 技术问答>java相关
我的JAVA JDK1.3.1_05 好像找不到CLASS,怎么解决?
来源: 互联网 发布时间:2015-10-13
本文导语: 我安装了JDK1.3.1_05,可用它编译一个很小的读写文件的程序都不能通过,命令行是 JAVAC MYTEST.JAVA ,好像是找不到 JAVA.IO.* CLASS,请问如何设置能找到CLASS?看资料好像不用设置CLASSPATH,我也设了PATH,是 C:JDK1.3.1_05; 谁能告诉我? ...
我安装了JDK1.3.1_05,可用它编译一个很小的读写文件的程序都不能通过,命令行是
JAVAC MYTEST.JAVA ,好像是找不到 JAVA.IO.*
CLASS,请问如何设置能找到CLASS?看资料好像不用设置CLASSPATH,我也设了PATH,是
C:JDK1.3.1_05; 谁能告诉我?
package mytest;
//import java.util.*;
import java.io.*;
public class fileprocess {
String filename;
BufferedReader br;
public boolean OpenFile(String name){
br = new BufferedReader(new FileReader( name ));
return true;
}
public String ReadOneLine() {
String st;
char c;
st = br.readLine();
return st;
}
}
mytest.java:15: unreported exception java.io.FilenotFoundException; must be caught or declared to be thrown
br = new BufferedReader(new FileReader( name ));
^
mytest.java:24: unreported exception java.io.IOException; must be caught or declared to be thrown
st = br.readLine();
^
JAVAC MYTEST.JAVA ,好像是找不到 JAVA.IO.*
CLASS,请问如何设置能找到CLASS?看资料好像不用设置CLASSPATH,我也设了PATH,是
C:JDK1.3.1_05; 谁能告诉我?
package mytest;
//import java.util.*;
import java.io.*;
public class fileprocess {
String filename;
BufferedReader br;
public boolean OpenFile(String name){
br = new BufferedReader(new FileReader( name ));
return true;
}
public String ReadOneLine() {
String st;
char c;
st = br.readLine();
return st;
}
}
mytest.java:15: unreported exception java.io.FilenotFoundException; must be caught or declared to be thrown
br = new BufferedReader(new FileReader( name ));
^
mytest.java:24: unreported exception java.io.IOException; must be caught or declared to be thrown
st = br.readLine();
^
|
大哥,你忘了声明异常的抛出了。
|
应该把语句放在try中。