gpt4 book ai didi

java.lang.NoClassDefFoundError : com/jcraft/jsch/JSch error in JSP file

转载 作者:行者123 更新时间:2023-12-01 14:59:33 29 4
gpt4 key购买 nike

我编写了一个连接到远程 LINUX 计算机并执行命令的程序。我使用 jsch-0.1.42.jar 文件连接到远程计算机。我的程序运行良好并返回输出。现在我想调用方法,该方法是使用以下代码从 JSP 在 Servlet 中声明的

<% SSHCommandExecutor sshce = new SSHCommandExecutor();
sshce.runCommnad();
%>

但是我收到以下错误

HTTP Status 500 -java.lang.NoClassDefFoundError: com/jcraft/jsch/JSch Servlet.service() for servlet jsp threw exception: java.lang.ClassNotFoundException: com.jcraft.jsch.JSch

最佳答案

在使用之前,您需要在 jsp 页面中导入该类,就像我们在普通 java 类中导入该类一样。

只是导入的方式不同而已。

我们在 package 语句之后(如果 package 语句存在)或作为第一个语句导入普通 java 类文件中的类。

在 jsp 中,我们在 page 指令中提到 import 属性,如下所示:

<%@ page language="java" contentType="text/html;charset=ISO-8859-1"   

import="com.jcraft.jsch.JSch"%>

the above lines comes at the top of the jsp page

....

rest of the jsp page

关于java.lang.NoClassDefFoundError : com/jcraft/jsch/JSch error in JSP file,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13877120/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com