如何在窗口azure中運行java tcp服務器? 可以窗口蔚藍嗎?如何在窗口azure中運行java tcp服務器?
我發現很多關於java窗口azure的應用的文章,他們是在eclipse中打開JSP web項目,而不是使用worker角色在窗口azure中發佈它,但是我的tcp服務器是一般的java項目,所以如何發佈到窗口天藍色?
我TCP服務器:
public class test {
private static int serverport = 12345;
private static ServerSocket serverSocket;
public static void main(String[] args) {
try {
serverSocket = new ServerSocket(serverport);
System.out.println("Server is start.");
while (!serverSocket.isClosed()) {
System.out.println("Wait new clinet connect!");
waitNewPlayer();
}
} catch (IOException e) {
System.out.println("Server Socket ERROR");
}
}
public static void waitNewPlayer() {
try {
Socket socket = serverSocket.accept();
System.out.println(socket.getInetAddress().getHostAddress()+"'s socket is connected now!");
createNewUser(socket);
} catch (IOException e) {
}
}
public static void createNewUser(final Socket socket) {
Thread t = new Thread(new Runnable() {
@Override
public void run() {
try {
PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(socket.getOutputStream())),true);
out.println("nangnang");
} catch (IOException e) {
System.out.println("Socket is closed!");
}
System.out.println("This socket is removed form the player array!");
}
});
t.start();
}
}
您能否一步一步展示流程,或者給我一個詳細的教程。 您是否將eclipse中的java項目導出到jar文件?並將jar文件放入天藍色項目中,如war文件? – nang531
http://java.interopbridges.com/articles/deploying-a-java-application-to-windows-azure-with-eclipse 我按照這篇文章一步一步,我把jre7.zip文件和apache-tomcat -7.0.34.zip文件在workerrole/approot/JRE和workerrole/approle/tomcat中,但是我不知道下一步怎麼做,因爲文章的下一步是針對jsp,但是我的java項目不是jsp項目,我無法導出戰爭文件,所以我不知道下一步該怎麼做。 – nang531