Beruflich Dokumente
Kultur Dokumente
INDEX
Sr.
Topic Date Page Sign
No.
PART I – J2ME
Sr.
Topic Date Page Sign
No.
PRACTICAL No. 1
Program 1:
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import java.io.*;
import java.util.*;
Program 2:
import javax.microedition.lcdui.*;
import javax.microedition.media.*;
import java.io.*;
Command.SCREEN,1);
private Command textcolor = new Command("TEXTCOLOR",
Command.SCREEN,1);
private Command fontstyle = new Command("CHANGE
FONTSTYLE",
Command.SCREEN,1);
private Command fontsize = new Command("CHANGE
FONTSIZE",
Command.SCREEN,1);
Wireless Technology & Mobile Communication Practical Journal
Command.SCREEN,1);
static java.util.Random random = new java.util.Random();
case 2:
g.setColor(bcol);
g.fillRect(0,0,width,height);
fcol=random.nextInt()>>>1;
g.setColor(fcol);
g.drawString(str2,4,4,Graphics.TOP
|Graphics.LEFT);
break;
Wireless Technology & Mobile Communication Practical Journal
case 3:
g.setColor(bcol);
g.fillRect(0,0,width,height);
g.setFont(Font.getFont(Font.FACE_MO
NOSPACE,Font.STYLE_ITALIC,
Font.SIZE_SMALL));
sty=0;
g.setColor(fcol);
g.drawString(str2,4,4,Graphics.TOP
|Graphics.LEFT);
break;
case 4:
g.setColor(bcol);
g.fillRect(0,0,width,height);
g.setFont(Font.getFont(Font.FACE_
MONOSPACE,Font.STYLE_PLAIN,
Font.SIZE_SMALL));
sty=1;
g.setColor(fcol);
g.drawString(str2,4,4,Graphics.TOP
|Graphics.LEFT);
break;
case 5:
g.setColor(bcol);
g.fillRect(0,0,width,height);
g.setFont(Font.getFont(Font.FACE_
MONOSPACE,Font.STYLE_ITALIC,
Font.SIZE_SMALL));
g.setColor(fcol);
g.drawString(str2,4,4,Graphics.TOP
|Graphics.LEFT);
break;
case 6:
g.setColor(bcol);
g.fillRect(0,0,width,height);
g.setFont(Font.getFont(Font.FACE_
MONOSPACE,Font.STYLE_ITALIC,
Font.SIZE_LARGE));
g.setColor(fcol);
g.drawString(str2,4,4,Graphics.TOP
|Graphics.LEFT);
Wireless Technology & Mobile Communication Practical Journal
break;
case 7:
g.setColor(bcol);
g.fillRect(0,0,width,height);
g.setFont(Font.getFont(Font.FACE_
MONOSPACE,Font.STYLE_PLAIN,
Font.SIZE_SMALL));
g.setColor(fcol);
g.drawString(str2,4,4,Graphics.TOP
|Graphics.LEFT);
break;
case 8:
g.setColor(bcol);
g.fillRect(0,0,width,height);
g.setFont(Font.getFont(Font.FACE_
MONOSPACE,Font.STYLE_PLAIN,
t.SIZE_LARGE));
g.setColor(fcol);
g.drawString(str2,4,4,Graphics.TOP
|Graphics.LEFT);
break;
default:
break;
}
}
public void commandAction(Command c, Displayable d)
{
if (c==background)
{
i=1;
repaint();
}
else if(c==textcolor)
{
i=2;
repaint();
}
else if(c==fontstyle)
{
if(j==1)
{
i=3;
sty=0;
Wireless Technology & Mobile Communication Practical Journal
j=0;
}
else
{
j=1;
sty=1;
i=4;
}
repaint();
}
else if(c==fontsize)
{
if(j==1 && sty==1)
{
i=5;
sty=0;
}
else if(j==1 && sty==0)
{
i=6;
sty=1;
}
else if(j==0 && sty==1)
{
i=7;
sty=0;
}
else if(j==0 && sty==0)
{
i=8;
sty=1;
}
}
}
public void pauseApp()
{}
public void destroyApp(boolean unconditional)
{}
}
Wireless Technology & Mobile Communication Practical Journal
OUTPUT:
Wireless Technology & Mobile Communication Practical Journal
Wireless Technology & Mobile Communication Practical Journal
Wireless Technology & Mobile Communication Practical Journal
PRACTICAL No. 2
Program:
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
public class Calc extends MIDlet implements CommandListener
{
Display disp;
TextField tf1,tf2,tf3;
Form form;
Command add,sub,mul,div,mod,exit;
public Calc()
{
disp=Display.getDisplay(this);
form=new Form("Addition of two nos");
tf1=new TextField("First no.","0",30,TextField.ANY);
tf2=new TextField("Second no.","0",30,TextField.ANY);
tf3=new TextField("Result","0",30,TextField.ANY);
form.append(tf1);
form.append(tf2);
form.append(tf3);
add=new Command("add",Command.SCREEN,1);
sub=new Command("subtract",Command.SCREEN,1);
mul=new Command("multiply",Command.SCREEN,1);
div=new Command("Divide",Command.SCREEN,1);
mod=new Command("modulus",Command.SCREEN,1);
exit=new Command("Exit",Command.EXIT,2);
form.addCommand(add);
form.addCommand(sub);
form.addCommand(mul);
form.addCommand(div);
form.addCommand(mod);
form.addCommand(exit);
form.setCommandListener(this);
}
public void startApp()
{
Wireless Technology & Mobile Communication Practical Journal
disp.setCurrent(form);
}
public void pauseApp()
{}
public void destroyApp(boolean unconditional)
{}
if(b==0)
tf3.setString("Divisor cannot be zero");
else
{
int c1=a%b;
tf3.setString(String.valueOf(c1));
}
}
if(c==exit)
{
destroyApp(false);
notifyDestroyed();
}
}
}
OUTPUT:
Wireless Technology & Mobile Communication Practical Journal
PRACTICAL No. 3
Program:
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import java.lang.*;
public QuizDemo()
{
disp=Display.getDisplay(this);
exit=new Command("Exit",Command.EXIT,1);
submit=new Command("Submit",Command.SCREEN,2);
next1=new Command("Next",Command.SCREEN,1);
next2=new Command("Next",Command.SCREEN,1);
next3=new Command("Next",Command.SCREEN,1);
msg=new TextBox("Message","Congrats",80,0);
form1.addCommand(next1);
form2.addCommand(next2);
form3.addCommand(next3);
form4.addCommand(submit);
form4.addCommand(exit);
form1.setCommandListener(this);
form2.setCommandListener(this);
Wireless Technology & Mobile Communication Practical Journal
form3.setCommandListener(this);
form4.setCommandListener(this);
form1.setItemStateListener(this);
form2.setItemStateListener(this);
form3.setItemStateListener(this);
form4.setItemStateListener(this);
}
public void destroyApp(boolean unconditional)
{
}
if(item==rdb2)
{
String ans=(rdb2.getString(rdb2.getSelectedIndex()));
if(ans.equals("Tokiyo"))
{
flag++;
}
Wireless Technology & Mobile Communication Practical Journal
}
if(item==rdb3)
{
String ans=(rdb3.getString(rdb3.getSelectedIndex()));
if(ans.equals("London"))
{
flag++;
}
}
if(item==rdb4)
{
String ans=(rdb4.getString(rdb4.getSelectedIndex()));
if(ans.equals("Kairo"))
{
flag++;
}
form4.append(msg1);
}
}
Wireless Technology & Mobile Communication Practical Journal
PRACTICAL No. 4
Program:
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
public class Currency extends MIDlet implements CommandListener
{
Display disp;
TextField tf1,tf2;
Form form;
Command US,UK,Japan,exit;
public Currency()
{
disp=Display.getDisplay(this);
form=new Form("Conversion of Currency");
tf1=new TextField("Indian Currency","0",30,TextField.ANY);
tf2=new TextField("Foreign Currency","0",30,TextField.ANY);
form.append(tf1);
form.append(tf2);
US=new Command("US",Command.SCREEN,1);
UK=new Command("UK",Command.SCREEN,1);
Japan=new Command("Japan",Command.SCREEN,1);
exit=new Command("Exit",Command.EXIT,2);
form.addCommand(US);
form.addCommand(UK);
form.addCommand(Japan);
form.addCommand(exit);
form.setCommandListener(this);
}
public void startApp()
{
disp.setCurrent(form);
}
public void pauseApp()
{}
public void destroyApp(boolean unconditional)
{}
{
float a=Float.parseFloat(tf1.getString());
float c1=a/48;
tf2.setString(String.valueOf(c1)+"Dollars");
}
if(c==UK)
{
float a=Float.parseFloat(tf1.getString());
float c1=a/85;
tf2.setString(String.valueOf(c1)+"Pounds");
}
if(c==Japan)
{
int a=Integer.parseInt(tf1.getString());
int c1=a*2;
tf2.setString(String.valueOf(c1)+"Yen");
}
if(c==exit)
{
destroyApp(false);
notifyDestroyed();
}
}
}
Wireless Technology & Mobile Communication Practical Journal
OUTPUT
Wireless Technology & Mobile Communication Practical Journal
PRACTICAL No. 5
Program:
import javax.microedition.lcdui.*;
import javax.microedition.midlet.MIDlet;
import java.util.Date;
public CalenderMIDlet()
{
cal=new DateField("Date In",DateField.DATE);
}
}
Wireless Technology & Mobile Communication Practical Journal
OUTPUT
Wireless Technology & Mobile Communication Practical Journal
PRACTICAL No. 6
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
public MySnake()
{
dis=Display.getDisplay(this);
ds=new DrawSnake();
}
public DrawSnake()
{
x=0;
y=0;
dir=0;
Wireless Technology & Mobile Communication Practical Journal
quit=new Command("QUIT",Command.SCREEN,1);
addCommand(quit);
setCommandListener(this);
th=new Thread(this);
th.start();
}
switch(getGameAction(cd))
{
case Canvas.UP:
y-=5;
dir=1;
break;
case Canvas.DOWN:
y+=5;
dir=2;
break;
case Canvas.LEFT:
x-=5;
dir=3;
break;
case Canvas.RIGHT:
x+=5;
dir=4;
break;
}
else if(dir==3)
x-=5;
else if(dir==4)
x+=5;
repaint();
try
{
th.sleep(500);
}
catch (Exception ee)
{
}
}
PRACTICAL No. 7
Program:
import java.io.*;
import java.util.*;
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import javax.microedition.io.*;
String user;
String pwd;
public DBConn(MySQLConn midlet) {
this.midlet = midlet;
display = Display.getDisplay(midlet);
}
//os.writeUTF(db.trim());
os.writeUTF(user.trim());
os.writeUTF(pwd.trim());
os.flush();
os.close();
/* This method takes input from user like db,user and pwd and
pass to servlet */
public void connectDb(String user,String pwd) {
//this.db = db;
this.user = user;
this.pwd = pwd;
}
Servlet Code
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.sql.*;
// connect(user.toLowerCase().trim(), pwd.toLowerCase().trim());
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Wireless Technology & Mobile Communication Practical Journal
conn = DriverManager.getConnection("jdbc:odbc:Harshad");
Statement stmt = conn.createStatement();
int i = stmt.executeUpdate("insert into Login
values('"+user+"','"+pwd+"')");
if(i!=0)
{
out.println("data has been inserted");
}
else
{
out.println("data is not inserted");
}
}catch(Exception e)
{ e.printStackTrace(); }
out.println("Data:"+user+pwd);
in.close();
out.close();
out.flush();
}
public void doGet(HttpServletRequest request, HttpServletResponse
response) throws ServletException, IOException {
doPost(request,response);
}*/
}
Wireless Technology & Mobile Communication Practical Journal
Wireless Technology & Mobile Communication Practical Journal
Wireless Technology & Mobile Communication Practical Journal
PRACTICAL No. 8
Program:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.w3.org/MarkUp/SCHEMA/xhtml11.xs
d"
xml:lang="en" >
<head>
<title>This is the document title</title>
</head>
<body>
<p>Moved to <a href="http://example.org/">example.org</a>.</p>
</body>
</html>
Wireless Technology & Mobile Communication Practical Journal
Wireless Technology & Mobile Communication Practical Journal
PRACTICAL No. 9
Program:
<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN"
"http://www.wapforum.org/DTD/wml_1.1.xml">
<wml>
<card title="Anchor Tag">
<p><anchor>Next page <go href="text.wml"/></anchor></p>
</card>
</wml>
First page
Second Page
Wireless Technology & Mobile Communication Practical Journal
Wireless Technology & Mobile Communication Practical Journal
<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN"
"http://www.wapforum.org/DTD/wml_1.1.xml">
<wml>
<card title="Input">
<p>
Name: <input name="Name" size="15"/><br/>
Age: <input name="Age" size="15" format="*N"/><br/>
Sex: <input name="Sex" size="15"/>
</p>
</card>
</wml>
Wireless Technology & Mobile Communication Practical Journal
<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN"
"http://www.wapforum.org/DTD/wml_1.1.xml">
<wml>
<card>
<p>
<anchor>Go To Test<go href="text.wml"/></anchor>
</p>
</card>
</wml>
Wireless Technology & Mobile Communication Practical Journal
<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN"
"http://www.wapforum.org/DTD/wml_1.1.xml">
<wml>
<card>
<p>
<anchor>Previous Page<go href="pre.wml"/></anchor>
</p>
</card>
</wml>
Wireless Technology & Mobile Communication Practical Journal
<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN"
"http://www.wapforum.org/DTD/wml_1.1.xml">
<wml>
<card id="card1" title="Tutorial">
<do type="accept" label="Answer">
<go href="#card2"/>
</do>
<p><select name="name">
<option value="HTML">HTML Tutorial</option>
<option value="XML">XML Tutorial</option>
<option value="WAP">WAP Tutorial</option>
</select></p>
</card>
<card id="card2" title="Answer">
<p>You selected: $(name)</p>
</card>
</wml>
Wireless Technology & Mobile Communication Practical Journal
PRACTICAL No. 10
Que: File transfer between Laptop & Mobile phone using Bluetooth
Instructions:
Step 1
Step 2
Enable bluetooth on the cell phone. Each phone is different, but you should
be able to go to a settings menu, and select bluetooth. There should be an
option to enable bluetooth on the phone. Enable it, and make sure the phone
is visible.
Step 3
Allow the PC to search for devices. It should find the cell phone. If not, we
can try searching for the computer with the cell phone. Many times, with the
USB modules, they have trouble finding the cell, but the cell can find the
computer. The important part is that the devices connect, regardless of
which device finds which.
Step 4
Step 5
Enter any necessary security codes. If you do not know these codes, try the
defaults, (1234, last 4 digits of your phone number, etc.).
Step 6
Wireless Technology & Mobile Communication Practical Journal
Select the files on the computer that we want, and we should be able to right
click and select "send via bluetooth". Click this option, and let the files send.
OR
Step 4: Scroll to Bluetooth and press the scroll key till On is displayed.
Step 5: Scroll to My phone’s visibility and press the scroll key till Shown to all
is displayed.
Step 4: Click on Add.. and a pop-up “Add Bluetooth Device Wizard” would
displayed.
Step 5: Checked on “My device is set up and ready to be found” and press
Next.
Step 10: Enter the same 8 to 16 digit passkey that you have entered
previously and Press Ok.
Step 11: Please wait while your laptop is installing the Bluetooth.
Step 12: Press Finish when the Completing the “Add Bluetooth Device
Wizard” is displayed.