Click here to Skip to main content
13,043,865 members (48,233 online)
Rate this:
Please Sign up or sign in to vote.
See more:
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
import java.sql.*;
import javax.swing.*;
class Naviagte extends Applet implements ActionListener
	Button b1;
	URL order;
	public void init()
		b1=new Button("Click Here for Next Page");
        			order =new URL("C:\Program Files\Java\jdk1.6.0_13\bin\Next.html");   
        		catch(MalformedURLException e)
	public void actionPerformed(ActionEvent e)

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 17-Aug-12 3:44am
Wes Aday 17-Aug-12 10:08am
order =new URL("C:\\Program Files\\Java\\jdk1.6.0_13\\bin\\Next.html");

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

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.



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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170713.1 | Last Updated 17 Aug 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100