Click here to Skip to main content
15,867,141 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Java
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
import java.sql.*;
import javax.swing.*;
import java.io.*;
import java.net.*;

class Naviagte extends Applet implements ActionListener
{
	Button b1;
	URL order;
	public void init()
   	{
		b1=new Button("Click Here for Next Page");
        		b1.setBounds(150,320,150,40);
        		add(b1);
        		b1.addActionListener(this);

		try
       		{
        			order =new URL("C:\Program Files\Java\jdk1.6.0_13\bin\Next.html");   
        		}
        		catch(MalformedURLException e)
		{
        			System.out.println("HH");
        		}
	}	
	public void actionPerformed(ActionEvent e)
    	{
	        	if(e.getSource()==b1)
        		{
        			getAppletContext().showDocument(order);
        			System.out.println("HI");
        		}
	}
}

I am unable to run this code.
It gives error on complication, such as "illegal escape character" in line
order =new URL("C:\Program Files\Java\jdk1.6.0_13\bin\Next.html");

I have made a html file for Naviagte and Next as well I have made a java file for Next class, but I am still unable to run it.

Please help me.
Posted
v2
Comments
[no name] 17-Aug-12 10:08am    
order =new URL("C:\\Program Files\\Java\\jdk1.6.0_13\\bin\\Next.html");

1 solution

I do see a couple of problems here.

  1. The first one is the one you're concerned with. The common backslash is usally an escape character in strings to denote special characters like a tabulator via \t. So if you want to include a backslash in your strings you have to escape it with a backslash: \\.
  2. The second point is that a file path is not a URL. If you want to know the proper syntax for file URLs you should google exactly that: "File system URLs".
  3. I'm not sure what exactly you're trying to achieve, but groping around in the file system in the java installation's bin folder looks really fishy to me. I'm not sure an applet container would even allow the access to that folder on the clients computer.


Regards,

Manfred
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900