Chat java 365 palavras 2 páginas Exibir mais import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.lang.String; import java.net.InetSocketAddress; import java.net.ServerSocket; import java.net.Socket; import java.net.UnknownHostException; import java.util.Scanner; import javax.swing.JOptionPane; public class SimpleChat2 { public static void main(String[] args) { String hostt = null; int porrt; String portt = null; String a; Socket socket = new Socket(); a = JOptionPane.showInputDialog(null,"Iniciar Como Cliente?"); if (a.equals("sim")) { hostt = JOptionPane.showInputDialog(null,"Insira o host"); portt = JOptionPane.showInputDialog(null,"Insira a porta"); porrt = Integer.parseInt(portt); startClient(hostt,porrt); //non-static method startClient(int) cannot be referenced from a static context } else { portt = JOptionPane.showInputDialog(null,"Insira a porta"); porrt = Integer.parseInt(portt); startServer(porrt); // //non-static method startServer(int) cannot be referenced from a static context // } } private static void startClient(String host, int port) { try { Socket socket = new Socket(); socket.connect(new InetSocketAddress(host, port)); chat(socket);