Java-GetCodeBase and GetDocumentBase

GetCodeBase and GetDocumentBase

You will create applets that will need to explicitly  load media and text. Java will allow the applet to load data from the directory holding the html file that started the applet (the document base) and the directory from which the applet’s class file was loaded (the code base). These directories are returned by  getDocumentBase( ) and getCodeBase( ).

Program

1

Program Source

import java.applet.Applet;
import java.awt.Graphics;

public class Javaapp extends Applet{
   
    public void paint(Graphics g)
    {
        g.drawString("getCodeBase     : "+getCodeBase(), 20, 20); 
        g.drawString("getDocumentBase : "+getDocumentBase(), 20, 40);
    }
}

Leave a Comment