FTP java程序中的运行时错误:类型top不能分配给“java/net/socket”
我用3种不同的方式重新编码了FTP部分,并收到了不同行号的类似错误。谁能告诉我我做错了什么,或者这个错误到底意味着什么?我对编程/java不是一个完全的新手,但我的技能肯定有点生疏,所以在回答时请记住这一点 这个问题与我在使用的Eclipse环境中设置jar文件有关。我点击进入窗口>首选项>Java>安装的JRE并删除了JRE实例。然后我重新添加了jdk实例,这似乎纠正了这个问题。我相信这是因为当我最初在这台电脑上安装Eclipse时,我没有开发工具包 FTP库有问题,不是您的代码有问题。尝试重新下载它,从另一个网站下载一个合法的!或者从源代码处编译它。我自己从下载并添加到Eclipse库中。如果有人是可信的,我想应该是他们。你有什么建议吗?我将尝试从头重新下载它。FTP java程序中的运行时错误:类型top不能分配给“java/net/socket”,java,sockets,ftp,runtime,Java,Sockets,Ftp,Runtime,我用3种不同的方式重新编码了FTP部分,并收到了不同行号的类似错误。谁能告诉我我做错了什么,或者这个错误到底意味着什么?我对编程/java不是一个完全的新手,但我的技能肯定有点生疏,所以在回答时请记住这一点 这个问题与我在使用的Eclipse环境中设置jar文件有关。我点击进入窗口>首选项>Java>安装的JRE并删除了JRE实例。然后我重新添加了jdk实例,这似乎纠正了这个问题。我相信这是因为当我最初在这台电脑上安装Eclipse时,我没有开发工具包 FTP库有问题,不是您的代码有问题。尝试重
import java.io.*;
import java.util.*;
import org.apache.commons.net.ftp.FTP;
import org.apache.commons.net.ftp.FTPClient;
import java.sql.Timestamp;
public class PrintOutConvosFtp2
{
public static void main(String[] args) throws IOException
{
//Read in the conversation log
BufferedReader reader = new BufferedReader(new FileReader("C:/Documents and Settings/Cuckoo/Desktop/Syss-convos.LOG"));
FileWriter output = new FileWriter("C:/Documents and Settings/Cuckoo/Desktop/Conversations.html");
List<String> lines = new ArrayList<String>();
String line = null;
while ((line = reader.readLine()) != null)
//remove some unnecessary clutter from the log
{
if (!(line.contains("just hung up!!!") || line.contains("just left the Realm.")
|| line.contains("Hurry, I've many esoteric secrets to divulge, and welcome to BaDbOy's realm.")
|| line.contains("For custom MegaMud paths and additional information, check out the website:")
|| line.contains("Syss gossips: Discuss new ideas/issues & see the most up to date information on Facebook!")
|| line.contains("Syss gossips: http://www.facebook.com/groups/EsotericEdits/")
|| line.contains("Syss gossips: MME Dats, Megamud path files and quest walkthroughs are available at my site")
|| line.contains("Syss gossips: www.esoteric-edits.fhero.net")
|| line.contains("telepaths: @")
|| line.contains("I'm a bot. Try telepathing me with @commands.")
|| line.contains("Syss gossips: Remember, you can telepath me @commands for useful things like adding lives.")
|| line.contains("Syss gossips: Bring a friend, help keep mud alive!")
|| line.contains("You say \"http://esoteric-edits.fhero.net/\"")
|| line.contains("For a list of available commands, you can telepath me with @commands.")))
{
//make the dates american style
String day = line.substring(0,2);
String month = line.substring(3,5);
lines.add(month + "/" + day + line.substring(5));
}
}
//initialize the output file with HTML header
output.write("<html>");
output.write(System.getProperty("line.separator") + "\t<head>");
output.write(System.getProperty("line.separator") + "\t\t<link type=\"text/css\" rel=\"stylesheet\" href=\"stylesheet.css\"/>");
output.write(System.getProperty("line.separator") + "\t\t<title>Esoteric Edits BBS - Conversation Log</title>");
output.write(System.getProperty("line.separator") + "\t</head>");
output.write(System.getProperty("line.separator") + "\t<body>"+ System.getProperty("line.separator") + System.getProperty("line.separator"));
output.write(System.getProperty("line.separator") + "<div id='cssmenu'>");
output.write(System.getProperty("line.separator") + "\t\t<center><img src=\"logo_10_2.png\">");
output.write(System.getProperty("line.separator") + "<ul>");
output.write(System.getProperty("line.separator") + "\t<li> <a href='index.html'><span>Home</span></a></li>");
output.write(System.getProperty("line.separator") + "\t<li> <a href='downloads.html'><span>Downloads</span></a></li>");
output.write(System.getProperty("line.separator") + "\t<li> <a href='Quests.html'><span>Quest Walkthroughs</span></a></li>");
output.write(System.getProperty("line.separator") + "\t<li> <a href='https://www.facebook.com/groups/EsotericEdits/'><span>Facebook</span></a></li>");
output.write(System.getProperty("line.separator") + "\t<li> <a href='captures.html'><span>Captures</span></a></li>");
output.write(System.getProperty("line.separator") + "\t<li class='last'> <a href='FAQs.html'><span>FAQs</span></a></li>");
output.write(System.getProperty("line.separator") + "</ul></center>");
output.write(System.getProperty("line.separator") + "</div><div id='mainpage'>");
output.write(System.getProperty("line.separator") + "<center><img src=\"divider.png\"></center>");
//write out a new file with HTML coloration
for (ListIterator<String> iter = lines.listIterator(); iter.hasNext(); )
{
String currentline = iter.next();
output.write("<b>"); //make everything bold
if (currentline.contains("gangpaths: "))
{
output.write(System.getProperty("line.separator") + "<font color=\"#808000\">" + currentline + "<br></font>");
}
else if (currentline.contains("gossips: ") || currentline.contains("auctions: "))
{
output.write(System.getProperty("line.separator") + "<font color=\"#FF00FF\">" + currentline + "<br></font>");
}
else if (currentline.contains("Broadcast from "))
{
output.write(System.getProperty("line.separator") + "<font color=\"yellow\">" + currentline + "<br></font>");
}
else if (currentline.contains("says \"") || currentline.contains("greets you.") || currentline.contains("bows deeply.")
|| currentline.contains("breaks into a wide grin.") || currentline.contains("You say \"")
|| currentline.contains("nods affirmatively.") || currentline.contains("grin slyly"))
{
output.write(System.getProperty("line.separator") + "<font color=\"green\">" + currentline + "<br></font>");
}
else
{
output.write(System.getProperty("line.separator") + currentline + "<br>");
}
}
//finalize the HTML footer
output.write(System.getProperty("line.separator") + "</b>");
output.write(System.getProperty("line.separator") + "</div>");
output.write(System.getProperty("line.separator") + "</body>");
output.write(System.getProperty("line.separator") + "\t</html>");
output.close(); //file is finalized locally
//Log file to track successful FTPs
PrintWriter writer = new PrintWriter("C:/Documents and Settings/Cuckoo/Desktop/Convo-Upload.log");
//define variables for FTP process
String server = "12.34.12.34"; //this is a fake ip
int port = 21;
String user = "fake";
String pass = "password";
//begin FTP process to web server
FTPClient ftpClient = new FTPClient();
FileInputStream fis = null;
try {
File localFile = new File("C:/Documents and Settings/Cuckoo/Desktop/Conversations.html");
ftpClient.connect(server, port);
ftpClient.login(user, pass);
ftpClient.setFileType(FTP.BINARY_FILE_TYPE);
fis = new FileInputStream(localFile);
String remoteFile = "Conversations.html";
ftpClient.storeFile(remoteFile, fis);
java.util.Date currentDate = new java.util.Date();
Timestamp currentTimestamp = new Timestamp(currentDate.getTime());
writer.println("Successfully uploaded file as of " + currentTimestamp.toString());
ftpClient.logout();
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
if (fis != null) {
fis.close();
}
ftpClient.disconnect();
} catch (IOException e) {
e.printStackTrace();
}
}
writer.flush(); //flush
writer.close(); //close the logger
}
}
Exception in thread "main" java.lang.VerifyError: Instruction type does not match stack map
Exception Details:
Location:
org/apache/commons/net/ftp/FTPClient._openDataConnection_(Ljava/lang/String;Ljava/lang/String;)Ljava/net/Socket; @73: aload
Reason:
Type top (current frame, locals[4]) is not assignable to 'java/net/Socket' (stack map, locals[4])
Current Frame:
bci: @73
flags: { }
locals: { 'org/apache/commons/net/ftp/FTPClient', 'java/lang/String', 'java/lang/String', integer, top, 'java/net/ServerSocket' }
stack: { }
Stackmap Frame:
bci: @73
flags: { }
locals: { 'org/apache/commons/net/ftp/FTPClient', 'java/lang/String', 'java/lang/String', integer, 'java/net/Socket', 'java/net/ServerSocket' }
stack: { }
Bytecode:
0000000: 2ab4 0083 9900 0d2a b400 8305 9f00 0501
0000010: b02a b600 fec1 0196 3e2a b400 839a 00cb
0000020: 2ab4 0198 2ab7 019c 042a b701 9fb6 01a1
0000030: 3a05 1d99 001d 2a2a b701 a719 05b6 01aa
0000040: b601 afb8 01b3 9a00 2019 05b6 01b9 01b0
0000050: 2a2a b701 a719 05b6 01aa b601 bab8 01b3
0000060: 9a00 06a7 ffe6 2ab4 0099 0994 9e00 112a
0000070: 2ab4 0099 b601 bc9a 0006 a7ff cf2a 2b2c
0000080: b601 c0b8 01c4 9a00 06a7 ffc0 2ab4 006b
0000090: 9b00 0c19 052a b400 6bb6 01c7 1905 b601
00000a0: cb3a 042a b400 6b9b 000c 1904 2ab4 006b
00000b0: b601 cf2a b401 d09e 000c 1904 2ab4 01d0
00000c0: b601 d22a b401 d59e 0019 1904 2ab4 01d5
00000d0: b601 d7a7 000d 3a06 1905 b601 b919 06bf
00000e0: 1905 b601 b9a7 00ee 2ab6 01da 9a00 0b1d
00000f0: 9a00 0703 a700 0404 3605 1505 9900 1f2a
0000100: b601 dd11 00e5 a000 152a 2ab4 01e0 03b6
0000110: 01e4 c000 a8b6 01ea a700 241d 9900 0501
0000120: b02a b601 ec11 00e3 9f00 0501 b02a 2ab4
0000130: 01e0 03b6 01e4 c000 a8b6 01ef 2ab4 01f1
0000140: b601 f53a 042a b401 d09e 000c 1904 2ab4
0000150: 01d0 b601 d22a b401 d59e 000c 1904 2ab4
0000160: 01d5 b601 d72a b400 7fc6 0014 1904 bb01
0000170: fa59 2ab4 007f 03b7 01fc b601 ff2a b400
0000180: 6b9b 000c 1904 2ab4 006b b601 cf19 04bb
0000190: 01fa 592a b400 852a b400 87b7 0203 2ab4
00001a0: 0206 b602 092a b400 9909 949e 0015 2a2a
00001b0: b400 99b6 01bc 9a00 0a19 04b6 0175 01b0
00001c0: 2a2b 2cb6 01c0 b801 c49a 000a 1904 b601
00001d0: 7501 b02a b400 6d99 0041 2a19 04b6 020d
00001e0: 9a00 3819 04b6 0175 bb01 3159 bb00 b359
00001f0: 1302 11b7 00e0 1904 b602 13b6 0102 b600
0000200: e213 0216 b600 e22a b600 feb6 0102 b600
0000210: e2b6 00be b702 18bf 1904 b0
Exception Handler Table:
bci [50, 73] => handler: 214
bci [80, 214] => handler: 214
Stackmap Table:
same_frame(@17)
append_frame(@73,Integer,Object[#325],Object[#427])
full_frame(@80,{Object[#1],Object[#168],Object[#168],Integer,Top,Object[#427]},{})
same_frame(@102)
same_frame(@125)
same_frame(@140)
same_frame(@156)
full_frame(@179,{Object[#1],Object[#168],Object[#168],Integer,Object[#325],Object[#427]},{})
same_frame(@195)
same_frame(@211)
full_frame(@214,{Object[#1],Object[#168],Object[#168],Integer,Top,Object[#427]},{Object[#541]})
full_frame(@224,{Object[#1],Object[#168],Object[#168],Integer,Object[#325],Object[#427]},{})
chop_frame(@232,2)
same_frame(@247)
same_locals_1_stack_item_frame(@248,Integer)
full_frame(@283,{Object[#1],Object[#168],Object[#168],Integer,Top,Integer},{})
same_frame(@289)
same_frame(@301)
same_frame(@316)
full_frame(@341,{Object[#1],Object[#168],Object[#168],Integer,Object[#325],Integer},{})
same_frame(@357)
same_frame(@381)
same_frame(@397)
same_frame(@448)
chop_frame(@467,1)
same_frame_extended(@536)
at PrintOutConvosFtp2.main(PrintOutConvosFtp2.java:110)