this is my code to get an image named "hkkl.jpg" from documents and show it on applet. but it gives error saying:

illegal unicode escape at /user and /documents....

import java.applet.*;
import java.awt.*;
public class Test extends Applet{
Image i;
public void init(){

i=getImage("C:\users\both\documents","hkkl.jpg");
}
public void paint(Graphics g){
g.drawImage(i,10,10,this);
}
}

a.html file is

 <html>
               <applet code="Test.class" width="200" height="200">
               </applet>   
 </html>

Please help. I am using notepad for coding and command prompt to run it:

javac Test.java 
appletviewer a.html

\ is an escape character, eg \n = newline. For a single \ you need to code two \

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.