在命令提示符下运行jar文件时显示“未找到异常线程类” [英] while running jar file in command prompt showing "Exception thread class not found"

查看:74
本文介绍了在命令提示符下运行jar文件时显示“未找到异常线程类”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

服务器端程序





server side program


import java.net.*; 
import java.io.*; 
import java.util.Scanner;
public class Server 
{ 
    public static void main (String [] args ) throws IOException 
    { 
    int filesize=1022386; 
    int bytesRead; int currentTot = 0; 
      try
    {  
    ServerSocket serverSocket = new ServerSocket(9999); 
    Socket socket = serverSocket.accept(); 
    System.out.println("Accepted connection : " + socket);
    BufferedReader br=new BufferedReader(new InputStreamReader(socket.getInputStream()));    
    String temp=br.readLine();
    System.out.println("The mesage from client is::"+temp);
    PrintStream  pr=new PrintStream(socket.getOutputStream()); 
                String  str = "acknowledgement from server";
                pr.println(str);
    Scanner scanner = new Scanner(System.in);  
    String path_save = scanner.nextLine();
             
    byte [] bytearray = new byte [filesize]; 
    InputStream is = socket.getInputStream(); 
    FileOutputStream fos = new FileOutputStream(path_save); 
    BufferedOutputStream bos = new BufferedOutputStream(fos); 
    bytesRead = is.read(bytearray,0,bytearray.length); 
    currentTot = bytesRead; 
    
    
    
    do 
    { 
        bytesRead = is.read(bytearray, currentTot, (bytearray.length-currentTot)); 
        if(bytesRead >= 0) 
        currentTot += bytesRead; 
    } 
            while(bytesRead > -1); bos.write(bytearray, 0 , currentTot); 
            bos.flush(); bos.close(); socket.close();
    }
    catch(Exception ex)
        
    {
        System.err.println(ex.getClass().getName()+":"+ex.getMessage());
        System.exit(0);
        
    }
    }
}





客户端计划





client side program

import java.net.*; 
import java.io.*; 
import java.util.Scanner;
public class client 
{ 
    public static void main (String [] args ) throws IOException 
    { 
    int filesize=1022386; 
    int bytesRead; 
    int currentTot = 0; 
    try
    {
    Socket socket = new Socket("10.176.24.63",9999);
    Scanner scanner = new Scanner(System.in);  
    String path = scanner.nextLine();
    File transferFile = new File (path); 
                
        byte [] bytearray = new byte [(int)transferFile.length()]; 
        FileInputStream fin = new FileInputStream(transferFile); 
        BufferedInputStream bin = new BufferedInputStream(fin); 
        bin.read(bytearray,0,bytearray.length); 
        OutputStream os = socket.getOutputStream(); 
        PrintStream  pr=new PrintStream(socket.getOutputStream()); 
    
                    System.out.println("Enter the file name,type,path");
                    BufferedReader  br=new  BufferedReader(new InputStreamReader(System.in));  
                    String temp = br.readLine();
                    pr.println(temp);	
                    BufferedReader  ed=new  BufferedReader(new InputStreamReader(socket.getInputStream())); 
                    String  st = ed.readLine();
                    System.out.println(st);
        System.out.println("Sending Files..."); 
        os.write(bytearray,0,bytearray.length); 
        os.flush();
        socket.close(); 
        System.out.println("File transfer complete");
    }
        catch(Exception ex)
        {
            System.err.println(ex.getClass().getName()+":"+ex.getMessage());
            System.exit(0);
        }

    }
}

推荐答案

请使用IDE进行开发。 IDE会立即告诉您,您确实错过了导入类异常



Eclipse [ ^ ]



Netbeans [ ^ ](java SE版本非常好)



两者都是免费的,两者都将指导您完成开发过程。

没有人再步行开发了。没有理由不使用给定的工具。
PLEASE use an IDE for development. The IDE would tell you right away that you did miss to import the class Exception.

Eclipse[^]

Netbeans[^] (java SE Version is perfectly fine)

Both are free, both will guide you through the process of developing.
Nobody is developing by foot any more. There is no reason for not using the given tools.


这篇关于在命令提示符下运行jar文件时显示“未找到异常线程类”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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