Click here to Skip to main content
15,898,036 members
Home / Discussions / Java
   

Java

 
GeneralRe: Best books/Tutorials to learn Java.? Pin
Gowtham Gutha16-Nov-12 7:13
Gowtham Gutha16-Nov-12 7:13 
GeneralRe: Best books/Tutorials to learn Java.? Pin
Gowtham Gutha16-Nov-12 7:14
Gowtham Gutha16-Nov-12 7:14 
QuestionFIX Day Changed Problem Pin
techGaurav8-Oct-12 21:42
techGaurav8-Oct-12 21:42 
AnswerRe: FIX Day Changed Problem Pin
TorstenH.8-Oct-12 22:00
TorstenH.8-Oct-12 22:00 
AnswerRe: FIX Day Changed Problem Pin
Nagy Vilmos11-Oct-12 20:12
professionalNagy Vilmos11-Oct-12 20:12 
QuestionThreads in details Pin
Neo101016-Oct-12 0:16
Neo101016-Oct-12 0:16 
AnswerRe: Threads in details Pin
Nagy Vilmos8-Oct-12 0:54
professionalNagy Vilmos8-Oct-12 0:54 
Questionjava applet security issues Pin
Ponnampi5-Oct-12 18:01
Ponnampi5-Oct-12 18:01 
Ok I'm having this issue with my applet here. I compile it and run it and it always throws an exception. 'java.security.AccessControlException: access denied (java.net.SocketPermission asylym-mud.org connect, resolve)'

I've looked up many different possible solutions and the bulk of them state that I need to genereate a certificate for it and assign it via the 'grant' code to the 'jre/lib/security/java.policy' file. I've done all this and it still gives me the same exception. Any ideas anyone?

import java.applet.*;
import java.awt.*;
import java.io.*;
import java.net.*;
import javax.swing.*;
import javax.swing.event.*;
import java.awt.event.*;
import java.awt.TextField.*;
import java.lang.*;
import java.util.*;

public class AMClient extends JApplet implements ActionListener{
	static public Socket localSocket;
	static final long serialVersionUID = 42L;
    static public PrintWriter out;
    static public InputStream in;
    static public JFrame fAMClient;
	static public JPanel nPanel,cPanel,sPanel;
    static public JButton btnConnect;
    static public JTextField tfInput;
	static public JTextArea taMud;

	public void init()
    {
		        try
		        {
					System.out.println("1");
					System.getSecurityManager().checkPermission(new SocketPermission("asylum-mud.org", "connect"));
					localSocket = new Socket("asylum-mud.org", 6715);
					System.out.println("2");
					in = new BufferedInputStream(localSocket.getInputStream());
					System.out.println("3");
					out= new PrintWriter(localSocket.getOutputStream(),true);
				}
				catch(Exception e)
				{
					System.out.println(e);
		}
		tfInput= new JTextField(30);
		btnConnect = new JButton("Connect");
		taMud = new JTextArea(30,50);
		add(btnConnect);
		add(taMud);
		add(tfInput);
		//display d = new display();
        //getContentPane().add(d);
        btnConnect.addActionListener(this);
    }
    public void actionPerformed(ActionEvent e)
    {
		//makes sure source is the connect button
		//& disable the button so it won't call
		//upon itself while active.
        if(e.getSource() == btnConnect)
        {
			btnConnect.enable(false);
			//btnConnect.setVisible(false);
		}
        //Create the socket to asylum-mud.org 6715
        try
        {
			//While we have a connection
            // get user input value and store it as a string
			taMud.append("6");
			String stdInn;
			taMud.append("7");
			stdInn = slurp(in,4122 );
			taMud.append("8");
			taMud.append(stdInn);
			taMud.append("9");
			out.flush();
        }
        catch(Exception ioe)
        {
            System.out.println(ioe.getMessage());
        }
    }

    public static void main( String[] args )
    {
        try
        {
			System.out.println("1");
			localSocket = new Socket("asylum-mud.org", 6715);
			System.out.println("2");
			in = new BufferedInputStream(localSocket.getInputStream());
			System.out.println("3");
			out= new PrintWriter(localSocket.getOutputStream(),true);
		}
		catch(Exception e)
		{
			System.out.println(e);
		}
		fAMClient = new JFrame();
		System.out.println("init 1");
		JApplet aAMClient = new JApplet();
		aAMClient.init();

		fAMClient.getContentPane().add(aAMClient);
		fAMClient.setSize(1200, 1200);
        fAMClient.setVisible(true);
        fAMClient.setTitle("AbsentMirage Client");
        aAMClient.start();
    }

    public static String slurp(final InputStream is, final int bufferSize)
	{
		final char[] buffer = new char[bufferSize];
	    final StringBuilder slurpOut = new StringBuilder();
	    taMud.append("slurp1");
	    try
	    {
			taMud.append("slurp2");
		    final Reader slurpIn = new InputStreamReader(is, "UTF-8");
	        taMud.append("slurp3");
	        try
	        {
	             final int rsz = slurpIn.read(buffer, 0, buffer.length);
	             slurpOut.append(buffer, 0, rsz);
	        }
	        catch (IOException ex)
	        {
				System.out.println(ex);
	    	}
	    finally
	    {
			try
			{
				in.close();
			}
	        catch (IOException ex)
	        {
				System.out.println(ex);
			}
	    }
	  }
	  catch (UnsupportedEncodingException ex)
	  {
		  System.out.println(ex);
	  }
	  return out.toString();
	}

}

AnswerRe: java applet security issues Pin
Ponnampi5-Oct-12 18:12
Ponnampi5-Oct-12 18:12 
QuestionData Structures - ArrayDeque <T> extends AbstractList <T> Pin
Member 94884535-Oct-12 16:29
Member 94884535-Oct-12 16:29 
AnswerRe: Data Structures - ArrayDeque extends AbstractList Pin
TorstenH.5-Oct-12 21:36
TorstenH.5-Oct-12 21:36 
QuestionCreating a class that extends more than one class. Pin
Bill.Moo4-Oct-12 2:43
Bill.Moo4-Oct-12 2:43 
AnswerRe: Creating a class that extends more than one class. Pin
Nagy Vilmos4-Oct-12 3:00
professionalNagy Vilmos4-Oct-12 3:00 
GeneralRe: Creating a class that extends more than one class. Pin
Bill.Moo4-Oct-12 3:48
Bill.Moo4-Oct-12 3:48 
AnswerRe: Creating a class that extends more than one class. Pin
Peter_in_27804-Oct-12 3:03
professionalPeter_in_27804-Oct-12 3:03 
GeneralRe: Creating a class that extends more than one class. Pin
Bill.Moo4-Oct-12 3:59
Bill.Moo4-Oct-12 3:59 
GeneralRe: Creating a class that extends more than one class. Pin
Peter_in_27804-Oct-12 11:36
professionalPeter_in_27804-Oct-12 11:36 
AnswerRe: Creating a class that extends more than one class. Pin
pasztorpisti4-Oct-12 12:14
pasztorpisti4-Oct-12 12:14 
QuestionRe: Creating a class that extends more than one class. Pin
Monster Maker21-Oct-12 21:08
Monster Maker21-Oct-12 21:08 
AnswerRe: Creating a class that extends more than one class. Pin
Gowtham Gutha15-Nov-12 6:59
Gowtham Gutha15-Nov-12 6:59 
QuestionThread names Pin
Neo101014-Oct-12 1:19
Neo101014-Oct-12 1:19 
AnswerRe: Thread names Pin
Nagy Vilmos4-Oct-12 2:54
professionalNagy Vilmos4-Oct-12 2:54 
AnswerRe: Thread names Pin
Gowtham Gutha15-Nov-12 7:11
Gowtham Gutha15-Nov-12 7:11 
Questionget ethernet IP address Pin
hari3013-Oct-12 19:30
hari3013-Oct-12 19:30 
AnswerRe: get ethernet IP address Pin
TorstenH.3-Oct-12 19:58
TorstenH.3-Oct-12 19:58 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.