Thursday, February 27, 2014
Android development projects in the Eclipse environment, you can not create a server using Socket
Code is as follows:
package cn.zbvc.socket;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.net.ServerSocket;
import java.net.Socket;
public class Server implements Runnable {
@ Override
public void run () {
/ / TODO Auto-generated method stub
try {
ServerSocket serverSocket = new ServerSocket (54321);
while (true) {
Socket client = serverSocket.accept ();
System.out.println ("accept");
try {
BufferedReader in = new BufferedReader (new InputStreamReader (client.getInputStream ()));
String str = in.readLine ();
System.out.println ("read:" + str);
PrintWriter out = new PrintWriter (new OutputStreamWriter (client.getOutputStream ()), true);
out.println ("server message");
in.close ();
out.close ();
} Catch (Exception e) {
System.out.println (e.getMessage ());
e.printStackTrace ();
} Finally {
client.close ();
System.out.println ("close");
}
}
} Catch (Exception e) {
System.out.println (e.getMessage ());
}
}
public static void main (String a []) {
Thread desktopServierThread = new Thread (new Server ());
desktopServierThread.start ();
}
}
Run error:
#
# An unexpected error has been detected by Java Runtime Environment:
#
# Internal Error (434C41535326494C453041525345520E4350500B65), pid = 2164, tid = 5384
#
# Java VM: Java HotSpot (TM) Client VM (1.6.0_02-b06 mixed mode)
# An error report file with more information is saved as hs_err_pid2164.log
#
# If you would like to submit a bug report, please visit:
# Http://java.sun.com/webapps/bugreport/crash.jsp
#
Open hs_err_pid2164.log the following:
#
# An unexpected error has been detected by Java Runtime Environment:
#
# Internal Error (434C41535326494C453041525345520E4350500B65), pid = 2164, tid = 5384
#
# Java VM: Java HotSpot (TM) Client VM (1.6.0_02-b06 mixed mode)
# If you would like to submit a bug report, please visit:
# Http://java.sun.com/webapps/bugreport/crash.jsp
#
--------------- T H R E A D ---------------
Current thread (0x003f6400): JavaThread "Unknown thread" [_thread_in_vm, id = 5384]
Stack: [0x008d0000, 0x00920000)
[Error occurred during error reporting, step 110, id 0xc00000fd]
Native frames: (J = compiled Java code, j = interpreted, Vv = VM code, C = native code)
C [javaw.exe +0 xc4fc]
C [javaw.exe +0 x81b5]
C [kernel32.dll +0 xb729]
--------------- P R O C E S S ---------------
Java Threads: (=> current thread)
Other Threads:
VM state: not at safepoint (not fully initilizated)
VM Mutex / Monitor currently owned by a thread: None
Heap
def new generation total 960K, used 0K [0x029d0000, 0x02ad0000, 0x02eb0000)
eden space 896K, 0% used [0x029d0000, 0x029d0000, 0x02ab0000)
from space 64K, 0% used [0x02ab0000, 0x02ab0000, 0x02ac0000)
to space 64K, 0% used [0x02ac0000, 0x02ac0000, 0x02ad0000)
tenured generation total 4096K, used 0K [0x02eb0000, 0x032b0000, 0x069d0000)
the space 4096K, 0% used [0x02eb0000, 0x02eb0000, 0x02eb0200, 0x032b0000)
compacting perm gen total 12288K, used 99K [0x069d0000, 0x075d0000, 0x0a9d0000)
the space 12288K, 0% used [0x069d0000, 0x069e8d40, 0x069e8e00, 0x075d0000)
No shared spaces configured.
Dynamic libraries:
0x00400000 - 0x00423000 D: \ Program Files \ Java \ jdk1.6.0_02 \ bin \ javaw.exe
0x7c920000 - 0x7c9b6000 C: \ WINDOWS \ system32 \ ntdll.dll
0x7c800000 - 0x7c91e000 C: \ WINDOWS \ system32 \ kernel32.dll
0x77da0000 - 0x77e49000 C: \ WINDOWS \ system32 \ ADVAPI32.dll
0x77e50000 - 0x77ee3000 C: \ WINDOWS \ system32 \ RPCRT4.dll
0x77fc0000 - 0x77fd1000 C: \ WINDOWS \ system32 \ Secur32.dll
0x77d10000 - 0x77da0000 C: \ WINDOWS \ system32 \ USER32.dll
0x77ef0000 - 0x77f39000 C: \ WINDOWS \ system32 \ GDI32.dll
0x76300000 - 0x7631d000 C: \ WINDOWS \ system32 \ IMM32.DLL
0x62c20000 - 0x62c29000 C: \ WINDOWS \ system32 \ LPK.DLL
0x73fa0000 - 0x7400b000 C: \ WINDOWS \ system32 \ USP10.dll
0x7c340000 - 0x7c396000 D: \ Program Files \ Java \ jdk1.6.0_02 \ jre \ bin \ msvcr71.dll
0x6d870000 - 0x6dab9000 D: \ Program Files \ Java \ jdk1.6.0_02 \ jre \ bin \ client \ jvm.dll
0x76b10000 - 0x76b3a000 C: \ WINDOWS \ system32 \ WINMM.dll
0x6d3c0000 - 0x6d3c8000 D: \ Program Files \ Java \ jdk1.6.0_02 \ jre \ bin \ hpi.dll
0x76bc0000 - 0x76bcb000 C: \ WINDOWS \ system32 \ PSAPI.DLL
0x6d820000 - 0x6d82c000 D: \ Program Files \ Java \ jdk1.6.0_02 \ jre \ bin \ verify.dll
0x6d460000 - 0x6d47f000 D: \ Program Files \ Java \ jdk1.6.0_02 \ jre \ bin \ java.dll
0x6d860000 - 0x6d86f000 D: \ Program Files \ Java \ jdk1.6.0_02 \ jre \ bin \ zip.dll
VM Arguments:
jvm_args:-Dfile.encoding = GBK-Xbootclasspath: D: \ Android \ android-sdk \ platforms \ android-8 \ android.jar
java_command: cn.zbvc.socket.Server
Launcher Type: SUN_STANDARD
Environment Variables:
JAVA_HOME = D: \ Program Files \ Java \ jdk1.6.0_02
. CLASSPATH =; D: \ Program Files \ Java \ jdk1.6.0_02 \ lib \ dt.jar; D: \ Program Files \ Java \ jdk1.6.0_02 \ lib \ tools.jar
PATH = D :/ Program Files/Java/jdk1.6.0_02/bin/../jre/bin/client; D :/ Program Files/Java/jdk1.6.0_02/bin/../jre/bin; D: / Program Files/Java/jdk1.6.0_02/bin/../jre/lib/i386; C: \ WINDOWS \ system32; C: \ WINDOWS; C: \ WINDOWS \ System32 \ Wbem; C: \ Program Files \ Common Files \ Thunder Network \ KanKan \ Codecs; D: \ Program Files \ Java \ jdk1.6.0_02 \ bin; D: \ Program Files \ Java \ jdk1.6.0_02 \ jre \ bin; C: \ Program Files \ Microsoft SQL Server \ 80 \ Tools \ Binn \; C: \ Program Files \ Microsoft SQL Server \ 90 \ Tools \ binn \; C: \ Program Files \ Microsoft SQL Server \ 90 \ DTS \ Binn \; C: \ Program Files \ Microsoft SQL Server \ 90 \ Tools \ Binn \ VSShell \ Common7 \ IDE \; C: \ Program Files \ Microsoft Visual Studio 8 \ Common7 \ IDE \ PrivateAssemblies \; D: \ Android \ eclipse;
USERNAME = Administrator
OS = Windows_NT
PROCESSOR_IDENTIFIER = x86 Family 6 Model 23 Stepping 6, GenuineIntel
--------------- S Y S T E M ---------------
OS: Windows XP Build 2600 Service Pack 3
CPU: total 2 (2 cores per cpu, 1 threads per core) family 6 model 7 stepping 6, cmov, cx8, fxsr, mmx, sse, sse2, sse3, ssse3
Memory: 4k page, physical 2096172k (670996k free), swap 4194303k (4194303k free)
vm_info: Java HotSpot (TM) Client VM (1.6.0_02-b06) for windows-x86, built on Jul 12 2007 01:16:14 by "java_re" with unknown MS VC + +: 1310
Please help answer
<-! Main posts under Banner (D4) -><-! Posts under the main text (D5) ->
Reply:
Java and Android development environment configuration problems.
Reply:
You are saying that the environment variables? I have configured the way
Reply:
Thank you, has been resolved!
Reply:
What is the problem ah? ?
No comments:
Post a Comment