Recently writtenProgram, Use the ftpclient in Apache common net to upload files to the FTP server, or even fail. After two or three days of struggle, it cannot be solved.
After the Google search, I found that the following URL mentioned this thing:
Java 7 prevents ftp transfers on Windows Vista and 7 if firewall is on. Any ideas?
Http://stackoverflow.com/questions/6990663/java-7-prevents-ftp-transfers-on-windows-vista-and-7-if-firewall-is-on-any-idea
This is a Java bug (submit date, 11-aug-2011 ):
Http://bugs.sun.com/bugdatabase/view_bug.do? Bug_id = 7077696
But Sun marked this as a low-level bug.
The specific reason is: on a computer with IPv6 and IPv4 installed, IPv4 (the only difference between jdk7 and older releases is that the JDK is using IPv6 Sockets when IPv6 is enabled and so IPv4-mapped IPv6 addresses are used ), windows Firewall blocks the simulated IPv4 data.
I am surprised that it only blocks the FTP command PASV. It does not block FTP login operations.
Finally, Sun provides a solution: Add a JVM startup parameter:
Run-Djava.net. preferipv4stack = true(Which disables IPv6 and uses af_inet sockets exclusively)
It was tested to be valid.