我实现了一个Java程序,该程序将使用JSCH在远程服务器中连接并执行命令。问题是,每当我尝试连接到服务器时,都会出现以下异常:
com.jcraft.jsch.JSchException: Session.connect: java.security.InvalidAlgorithmParameterException: Prime size must be multiple of 64, and can only range from 256 to 2048 (inclusive)
Run Code Online (Sandbox Code Playgroud)
我尝试了在jre / lib和security.provider中添加Bouncy Castle提供程序的解决方案,它可以正常工作。但是我需要使其依赖于项目,因此我尝试在构建路径中添加Bouncy Castle,并在程序中手动添加Bouncy Castle提供程序。但是将其导出到jar后,我仍然收到异常。
package services;
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.security.Security;
import java.util.Iterator;
import java.util.Properties;
import org.bouncycastle.jce.provider.BouncyCastleProvider;
public class MainService {
public MainService() {
Security.addProvider(new BouncyCastleProvider()); //Adding BouncyCastlePRovider in security
// TODO Auto-generated constructor stub
String report = "";
StringBuilder sb = new StringBuilder();
System.out.println("Running the monitoring...");
System.out.println("Starting printer monitoring...");
PrinterService ps = …Run Code Online (Sandbox Code Playgroud) 我下载了 netbeans ide 11 并尝试做一个示例 hello world 项目,但它给了我错误“无法访问 java.lang 致命错误:无法在类路径或引导类路径中找到包 java.lang”我尝试了一些堆栈溢出的解决方案,但没有工作。
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package javaapplication1;
/**
*
* @author ahmad
*/
public class JavaApplication1 {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
System.out.println("Hello");
}
}
Run Code Online (Sandbox Code Playgroud)
我是java的初学者.我JPanel在java(NetBeans)中创建了一个表单.然后,我定义了一些动作,如数学计算.当我运行我的项目时,我没有收到任何错误,但我JPanel在运行时看不到表单.因为我没有在主类中定义jform.如何JPanel在主类中定义表单JPanel以在运行时向我显示表单.
public class NewJPanel extends javax.swing.JPanel {
public NewJPanel() {
initComponents();
}
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jTextField1 = new javax.swing.JTextField();
jTextField2 = new javax.swing.JTextField();
jTextField3 = new javax.swing.JTextField();
jButton1 = new javax.swing.JButton();
jButton2 = new javax.swing.JButton();
jButton3 = new javax.swing.JButton();
jButton4 = new javax.swing.JButton();
jButton5 = new javax.swing.JButton();
jLabel1.setText("First Number:");
jLabel2.setText("Second Number:");
jLabel3.setText("Result:");
jButton1.setText("Add"); …Run Code Online (Sandbox Code Playgroud)