抛出类未找到异常 [英] Class not found exception is thrown

查看:74
本文介绍了抛出类未找到异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好朋友,

我正在使用甜蜜的家庭3D API。

现在class.forName给我异常,因为找不到类。

即使我可以在编译时找到它。

我已将.jar文件放在web-inf的lib中。

请给我解决方案。





Hello friends,
I am using sweet home 3d API.
Now class.forName gives me the exception as class not found.
Even I can find it at compile time.
I have placed .jar file inside lib of web-inf.
please give me the solution on this.


package rohan.com;
import java.util.jar.*;
import java.io.IOException;
import java.io.PrintWriter;
import com.eteks.sweethome3d.SweetHome3D;
import com.eteks.sweethome3d.SweetHome3DBootstrap;
import com.eteks.sweethome3d.SweetHome3DJavaWebStartBootstrap;
import com.eteks.sweethome3d.model.Home;
import com.eteks.sweethome3d.model.HomeApplication;
import com.eteks.sweethome3d.swing.HomePane;
import com.eteks.sweethome3d.viewcontroller.HomeView;
import java.io.*;
import java.util.*;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


/**
 * Servlet implementation class RohanBhanu
 */
@WebServlet("/RohanBhanu")
public class RohanBhanu extends HttpServlet {
	private static final long serialVersionUID = 1L;

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		PrintWriter out=response.getWriter();


	    	  
	    try {
			Class exampleClass = Class.forName("com.eteks.sweethome3d");
		} catch (ClassNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			out.print(e.getMessage());
		}
}

	 private static void process(Object obj) {
	       
	     }
}

推荐答案

必须在META-INF / Manifest.mf文件的类路径中引用jar。看到你在战争中正确引用了该文件。您的部署目标也可能具有指定依赖项库的备用位置,例如conf文件。请查看服务器文档。
The jar must be referred in the classpath in the META-INF/Manifest.mf file. See that you have referred the file properly in the war. Your deployment target may also have alternate places of specifying dependency libraries, such as conf files. Check with your server documentation.


这篇关于抛出类未找到异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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