Wednesday, 28 March 2018

Learn how to compile java applet program from java command prompt


Learn how to compile java applet program from java command prompt

introduction

java applet program based on graphics that hold data in graphics form and source code

compile to object code yield result show in applet viewer application or you embedded

at browser application with source code method.applet application show result in
very fantastic form.

step1:click at start button then click at the Accessories option then click at
Command Prompt option
step2:type cd\ command to reached at prompt .
step3:type cd command to reach root
step4: type like this
 c:\>cd program files then press enter key
c:\program files>cd java then press enter key
c:\program files\java>dir then press enter key
note :dir command use show contents
c:\program files\java>cd jdk1.8.0_151 press enter key
c:\program files\java\ jdk1.8.0_151>cd bin press enter key
c:\program files\java\ jdk1.8.0_151>cd bin press enter key
c:\program files\java\ jdk1.8.0_151\ bin>md app press enter key
c:\program files\java\ jdk1.8.0_151\ bin>cd app press enter key
c:\program files\java\ jdk1.8.0_151\ bin\app>copy con myapplet.java press enter key
//type source code here
//source code
package app;
import java.applet.*;
import java.awt.*;
public class myapplet extends Applet
{
public void init()
{
}
public void pain(Graphics g)
{
g.drawString("myappliet program",100,100);
}
}
/*
<Applet code="app.class" width=400 height=400>
</Applet>
              */


press ctrl+z and press enter key.

c:\program files\java\ jdk1.8.0_151\ bin\app>cd..

c:\program files\java\ jdk1.8.0_151\ bin>javac  app\myapplet.java

c:\program files\java\ jdk1.8.0_151\ bin>appletviewer  app\myapplet.java

c:\program files\java\ jdk1.8.0_151\ bin>cd app press enter key

c:\program files\java\ jdk1.8.0_151\ bin\app>copy con RotateImage.java press enter key
//write source code here
import java.applet.Applet;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.geom.AffineTransform;
import java.net.URL;

public class RotateImage extends Applet {

private Image image;

AffineTransform identity = new AffineTransform();

 private URL getURL(String filename) {
 URL url = null;
 try {
 url = this.getClass().getResource(filename);
 }
catch(Exception e){}
return url;
}

public void init() {
image = getImage(getCodeBase(), "image.jpg");
}

public void paint(Graphics g) {
Graphics2D g2d = (Graphics2D)g;
AffineTransform trans = new AffineTransform();
trans.setTransform(identity);
trans.rotate( Math.toRadians(45) );
g2d.drawImage(image, trans, this);
}
}

/*
<Applet code="app.class" width=400 height=400>
</Applet>
              */

press f6  or ctrl+z

c:\program files\java\ jdk1.8.0_151\ bin\app>cd..

c:\program files\java\ jdk1.8.0_151\ bin>javac  app\RotateImage.java
c:\program files\java\ jdk1.8.0_151\ bin>appletviewer  app\myapplet.java

0 comments:

Post a Comment