AD: Create your own programming language
In tutorial 2 I will show you how to create an applet that will run on web pages based off of StartApp from tutorial 1.
This time around I will introduce the Eclipse IDE instead of using command line. Using an IDE such as Eclipse or NetBeans will make organizing your projects much easier. I suggest using Eclipse IDE if you want to get into developing for android
Below is the link for eclipse classic, all you need for now
http://www.eclipse.org/downloads/download.php?file=/eclipse/downloads/drops4/R-4.2-201206081400/eclipse-SDK-4.2-win32-x86_64.zip
- Once you've unzipped it where ever you like it
- Open eclipse and hit File> new>java project
and name it whatever you feel like and it will create a fresh new project space.
- Right click on your project folder in the project explorer and hit New>Class
import java.awt.*;
public class StartApplet extends javax.swing.JApplet {
public void paint(Graphics screen) {
Graphics2D screen2D = (Graphics2D) screen;
screen2D.drawString("Press Start to Begin", 10, 50);
}
}
Once you are done click on the green arrow on the top menu and the applet viewer will launch. You should see an applet window that prints out "Press start to begin"
Now to show you how to embed your applet to run in a web page
- Go into your eclipse workspace you set and find StartApplet.class in the bin directory. Bring up terminal and type: nano index.html
- In nano type:
<html>
<head>
<title>My Future Game</title>
</head>
<body>
<applet
code="StartApplet.class"
height="150"
width="300"
</applet>
</body>
</html>
Blam! Load your webpage and it should pop up with the applet embedded with your text printed to the screen.
No comments:
Post a Comment