den udskriver ingen fejl ved compile, men når jeg prøver at vise appleten melder den disse fejl:
java.lang.NullPointerException at java.applet.Applet.getParameter(Unknown Source) at z.<init>(z.java:19) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) at java.lang.reflect.Constructor.newInstance(Unknown Source) at java.lang.Class.newInstance0(Unknown Source) at java.lang.Class.newInstance(Unknown Source) at sun.applet.AppletPanel.createApplet(Unknown Source) at sun.plugin.AppletViewer.createApplet(Unknown Source) at sun.applet.AppletPanel.runLoader(Unknown Source) at sun.applet.AppletPanel.run(Unknown Source) at java.lang.Thread.run(Unknown Source) Exception in thread "Thread-4" java.lang.NullPointerException at sun.plugin.util.GrayBoxPainter.showLoadingError(Unknown Source) at sun.plugin.AppletViewer.showAppletException(Unknown Source) at sun.applet.AppletPanel.runLoader(Unknown Source) at sun.applet.AppletPanel.run(Unknown Source) at java.lang.Thread.run(Unknown Source) java.lang.NullPointerException at sun.plugin.util.GrayBoxPainter.showLoadingError(Unknown Source) at sun.plugin.AppletViewer.showAppletStatus(Unknown Source) at sun.applet.AppletPanel.run(Unknown Source) at java.lang.Thread.run(Unknown Source) Exception in thread "thread applet-z.class" java.lang.NullPointerException at sun.plugin.util.GrayBoxPainter.showLoadingError(Unknown Source) at sun.plugin.AppletViewer.showAppletException(Unknown Source) at sun.applet.AppletPanel.run(Unknown Source) at java.lang.Thread.run(Unknown Source)
java.security.AccessControlException: access denied (java.net.SocketPermission siden.dk resolve) at java.security.AccessControlContext.checkPermission(Unknown Source) at java.security.AccessController.checkPermission(Unknown Source) at java.lang.SecurityManager.checkPermission(Unknown Source) at java.lang.SecurityManager.checkConnect(Unknown Source) at java.net.InetAddress.getAllByName0(Unknown Source) at java.net.InetAddress.getAllByName0(Unknown Source) at java.net.InetAddress.getAllByName(Unknown Source) at java.net.InetAddress.getByName(Unknown Source) at java.net.InetSocketAddress.<init>(Unknown Source) at java.net.Socket.<init>(Unknown Source) at z.init(z.java:32) at sun.applet.AppletPanel.run(Unknown Source) at java.lang.Thread.run(Unknown Source) Exception in thread "thread applet-z.class" java.lang.NullPointerException at sun.plugin.util.GrayBoxPainter.showLoadingError(Unknown Source) at sun.plugin.AppletViewer.showAppletException(Unknown Source) at sun.applet.AppletPanel.run(Unknown Source) at java.lang.Thread.run(Unknown Source)
Har fundet ud af, det fordi je ikke har adgang til at skrive kommandoer.
men kører den på localhost siger den: Svar fra client: Kunne ikke oprette forbindelse! java.net.ConnectException: Connection refused: connect at java.net.PlainSocketImpl.socketConnect(Native Method) at java.net.PlainSocketImpl.doConnect(Unknown Source) at java.net.PlainSocketImpl.connectToAddress(Unknown Source) at java.net.PlainSocketImpl.connect(Unknown Source) at java.net.SocksSocketImpl.connect(Unknown Source) at java.net.Socket.connect(Unknown Source) at java.net.Socket.connect(Unknown Source) at java.net.Socket.<init>(Unknown Source) at java.net.Socket.<init>(Unknown Source) at z.init(z.java:32) at sun.applet.AppletPanel.run(Unknown Source) at java.lang.Thread.run(Unknown Source) java.security.AccessControlException: access denied (java.lang.RuntimePermission exitVM) at java.security.AccessControlContext.checkPermission(Unknown Source) at java.security.AccessController.checkPermission(Unknown Source) at java.lang.SecurityManager.checkPermission(Unknown Source) at java.lang.SecurityManager.checkExit(Unknown Source) at java.lang.Runtime.exit(Unknown Source) at java.lang.System.exit(Unknown Source) at z.init(z.java:40) at sun.applet.AppletPanel.run(Unknown Source) at java.lang.Thread.run(Unknown Source) Exception in thread "thread applet-z.class" java.lang.NullPointerException at sun.plugin.util.GrayBoxPainter.showLoadingError(Unknown Source) at sun.plugin.AppletViewer.showAppletException(Unknown Source) at sun.applet.AppletPanel.run(Unknown Source) at java.lang.Thread.run(Unknown Source)
try { System.out.println("Her connecter den"); sock = new Socket("localhost",80); } catch (UnknownHostException a) { System.out.println("Svar fra client: Du fik ikke adgang!"); a.printStackTrace(); System.exit(1); } catch (IOException ioe) { System.out.println("Svar fra client: Kunne ikke oprette forbindelse!"); ioe.printStackTrace(); System.exit(1); } try { InputStream ind = sock.getInputStream(); OutputStream ud = sock.getOutputStream(); System.out.println("Her skulle den svarer tilbage"); ud.write("Du svarede tilbage!".getBytes()); int MAX_SIZE = 16384; byte[] buffer = new byte[MAX_SIZE]; System.out.println("Her skulle den vise hvad den fik"); while (true) { int laes = ind.read(buffer,0,MAX_SIZE); System.out.println("Client modtog: "+new String(buffer,0,laes)); if (laes < MAX_SIZE) break; } sock.close(); } catch (IOException e) { e.printStackTrace(); } } public void paint(Graphics g) { bufferGfx.clearRect(0,0,this.getWidth(),this.getHeight());
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.