Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/397.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java更新后Eclipse中的FileNotFoundException_Java_Servlets_File Upload - Fatal编程技术网

Java更新后Eclipse中的FileNotFoundException

Java更新后Eclipse中的FileNotFoundException,java,servlets,file-upload,Java,Servlets,File Upload,我有一个程序,客户端上传一个文件,文件存储在数据库中。在我的计算机上进行Java更新之前,我的项目运行良好。现在我得到一个FileNotFoundException。Eclipse告诉我: JAR文件C:\Program Files\Java\jre7\lib\rt.JAR没有源代码 附件 有人遇到过这个问题吗 我上传文件的servlet代码是标准的: if (!ServletFileUpload.isMultipartContent(request)) {return;} try

我有一个程序,客户端上传一个文件,文件存储在数据库中。在我的计算机上进行Java更新之前,我的项目运行良好。现在我得到一个
FileNotFoundException
。Eclipse告诉我:

JAR文件C:\Program Files\Java\jre7\lib\rt.JAR没有源代码 附件

有人遇到过这个问题吗

我上传文件的servlet代码是标准的:

if (!ServletFileUpload.isMultipartContent(request))
    {return;}

try 
{ 
  List<FileItem> items = new ServletFileUpload(new DiskFileItemFactory()).parseRequest(request);
  courseID = items.get(0).getString();
  homeworkID = items.get(1).getString();
  File storeFile = new File(items.get(2).getName());
  String fileName = storeFile.getName();
  String mimeType = new MimetypesFileTypeMap().getContentType(storeFile); //for putting file into database
  putFileIntoDB(uName, courseID, homeworkID, fileName, mimeType, storeFile);
}//try
 catch (Exception ex)
 {
   request.setAttribute("msg", "There was an error: " + ex.getMessage());
   request.getRequestDispatcher("/upload.jsp").forward(request, response);
  }
还有其他人遇到这个问题吗?

尝试以下步骤

步骤1-配置Eclipse以使用JDK而不是JRE

Window->Preferences->Java->Installed JREs
Click "Add", "Standard VM", "Next"
For "JRE Home" click "Directory"
Locate your JDK directory...
Ex: C:\java\jdk1.6.0_24
Click "Finish"
Next check the JDK vs the JRE that is listed.
Click "Ok"
步骤2-将项目配置为使用JDK,因为它是用JRE作为“已安装的JRE”创建的。新项目应该可以

Right click the project's name.
Choose "Properties", "Java Build Path"
Click the tab "Libraries".
Click "Add Libraries", select "JRE System Library", Next
Select the bottom item: Workspace default JRE (jdk1.x.x. etc....)
(Notice that it is now a JDK and not the JRE!)
Click "Finish"
Now remove the JRE libarary so you only have the JDK library.
ex: JRE System Library [JavaSE-1.6]
Click "OK"

您是否检查过该位置上是否有该jar?是的,当我导航到该位置时,rt.jar文件就在那里。这就是为什么我不明白为什么它告诉我它没有源附件。我试过了,不幸的是我仍然有同样的问题。我不知道我的eclipse设置发生了什么。我正在考虑取消安装并重新安装。你知道有没有办法恢复到以前的工作时间吗?没有,你不能恢复。请在此处查看类似的isse:
Right click the project's name.
Choose "Properties", "Java Build Path"
Click the tab "Libraries".
Click "Add Libraries", select "JRE System Library", Next
Select the bottom item: Workspace default JRE (jdk1.x.x. etc....)
(Notice that it is now a JDK and not the JRE!)
Click "Finish"
Now remove the JRE libarary so you only have the JDK library.
ex: JRE System Library [JavaSE-1.6]
Click "OK"