Showing posts with label JAVA. Show all posts
Showing posts with label JAVA. Show all posts

Tuesday, September 6, 2011

ARRAY

import java.util.*;
class Sam
{
public static void main(String args[])
{
int a[]={10,20,30};
System.out.println(a[2]);

int b[]=new int[4];
b[2]=100;
System.out.println(b[2]);

String s[]=new String[3];
System.out.println(s.length);
for(int i=0;i<s.length;i++)
{
Scanner sc=new Scanner(System.in);
s[i]=sc.nextLine();
}
System.out.println("You Entered");
int j=0;
while(j<s.length)
{
System.out.println(s[j]);
j++;
}
}
}

If U LIKE THE POST FOLLOW THE BLOG

SCANNER USAGE

import java.util.*;
class Sam
{
public static void main(String args[])
{
Scanner s=new Scanner(System.in);
System.out.println("enter name");

String name=s.nextLine();

System.out.println("Enter Age");

int age=s.nextInt();

System.out.println("Enter Salary");

float f=s.nextFloat();

System.out.println("Gender");
String cc=s.next();

char c=cc.charAt(0);

System.out.println(name);
System.out.println(age);
System.out.println(f);
System.out.println(c);

}
}

If U LIKE THE POST FOLLOW THE BLOG

PROGRAM TO FIND AVERAGE

PROGRAM TO FIND AVERAGE

import java.util.*;
class Sam
{
public static void main(String args[])
{
float avg;
int n,sum=0;
Scanner s=new Scanner(System.in);

int i=0;

while(i<10)
{
n=s.nextInt();
sum=sum+n;
i++;
}

System.out.println(sum);
avg=sum/10;
System.out.println(avg);
}
}
If U LIKE THE POST FOLLOW THE BLOG

program to check vowel or not

program to check vowel or not
import java.util.*;
class Sam
{
public static void main(String args[])
{
Scanner s=new Scanner(System.in);

System.out.println("Enter Char");

String s1=s.next();

char c=s1.charAt(0);

if( c=='a' || c=='e' || c=='i' || c=='o' || c=='u' || c=='A' || c=='E' || c=='I' ||c=='O' || c=='U' )
{
System.out.println("It is a Vowel");
}
else
{
System.out.println("Not a Vowel");
}
}
}

If U LIKE THE POST FOLLOW THE BLOG

Saturday, August 6, 2011

Android Installation on Windows7

Android Installation on Windows7 and Creating a Simple Hello World Program

 

Mobility is driving you crazy .

You wish to create a simple "HelloWorld" program that runs on Android OS. …

But you are now confused as to ….How do I go about it or where do I start ? 

This post is for "Beginners in Android". So if you are completely new, this post should be of help

What Is Android ? 

Android is an operating system for mobile devices. Applications developed for Android are written in Java programming language.


How do I setup the enviornment for developing applications on Android? 

To setup the environment , follow these simple steps:

1) Identify the operating system on your PC. Verify whether it is listed in the "Supported Operating Systems" section. Click on this link to verify http://developer.android.com/sdk/requirements.html

2)  Applications for Android are written using Java programming language.Set up the environment to "DEVELOP" Java Programs.

If you have to only run Java programs, then install Java Runtime Environment(JRE). But we will be developing programs, so install Java Development Kit(JDK) which includes JRE . There is no need of separate installation of JRE if JDK is installed.

Note: Identify the operating system and choose the correct version of JDK. 

Click on below link to install JDK : http://www.oracle.com/technetwork/java/javase/index-137561.html
 
3) Surely you won’t write programs in Notepad. You will use an IDE(Integrated Development Environment) to code your applications. Preferred IDE would be Eclipse, but applications can be developed using other IDEs.

To install Eclipse , select proper version of Eclipse(3.5 or newer).

Click on below link : http://www.eclipse.org/downloads/
4)  To code applications , download the Android SDK . Android SDK provides tools and APIs to develop programs for Android OS. Download the Android SDK from this link : http://developer.android.com/sdk/index.html
5)  Your installed Eclipse IDE should be capable of developing Android programs. So install the ADT plugin for Eclipse. Click here to install the same : http://developer.android.com/sdk/eclipse-adt.html#installing
 
6) This is last but very important step. Install the essential platform components to complete the installation. This is done using Android SDK and AVD Manager which is installed once you install the SDK.

The above steps may differ depending upon your previous installations if you were developing Java programs. You can log on to http://developer.android.com/guide/basics/what-is-android.html to know more .

If U LIKE THE POST FOLLOW THE BLOG

Thursday, February 24, 2011

How To Make NoProxy and NoPort version of Handler Apps --- blue modding world

How To Make NoProxy and NoPort version of Handler Apps --- blue modding world

 

 1. Extract the classes
2. Search in between classes the string: X-Online-Host
3. Edit it all and change to Host
4. Edit the hex byte length counter value 0D to 04. It is before start of X-Online-Host hex code.
5. Save and repack. Done!



Note: you can do this via X-plore.

Tips: use javatool(a python app) to easily know which class contains the x-online-host term.

How To Use NoProxyNoPort mod
on handler menu.
Set USE PROXY: HOST
PROXY/HOST: 
credits?
Yk_Handler for handlerUI
Superben for teaching me this
CAST for inspiring
Yakisara for Javatool

(screenshots to follow..)


Attachment

Finding in class.png (8.82 KB)
 Finding in class.png
Before edit.png (8.37 KB)
 Before edit.png
After edit.png (8.3 KB)
 After edit.png
Using Javatools.png (13.47 KB)
 Using Javatools.png
Using Javatools2.png (9.11 KB)
 Using Javatools2.png
ConnectionSettings.png (10.77 KB)
 ConnectionSettings.png
HandlerUI132Settings Sample.png (8.83 KB)
 HandlerUI132Settings Sample.png





























































































In Class Translator 1.1 edit java in seconds

In Class Translator is a program for edit and modify the class files in jar softwares and games.












This program is designed to edit and translate (mod) the class files in jar softwares and games, It is able to recognize text in "class" files, and allows you to change or edit them.

What's New
Version 1.1
- "About" Windows Added
- Minor Bugs Fixed
- Icon Changed



How to...
1. Unpack all classes (*.class) files from jar file with WinRAR (or any other archiver).
2. Open "In Class Translator.exe" by double click on it!
3. Click "Open" button to browse for class file.
4. Edit your class file.
5. Click "Save" button to save your edited file.
6. If you want to "Save as...", see the "File" menu.
7. When you done editing, just drag and drop edited file to the JAR archive.
8. Transfer JAR file to phone and install.



Download PDF Tutorial



Download from softpedia.com

Mirror Download Links:
Download from 4shared.com
Download from Soft82.com
Download from appronic.com
Download from fiberdownload.com

Old Version:
Download Version 1.0



Sunday, February 20, 2011

Mail Application Client Code

import java.util.Properties;
import javax.mail.Authenticator;
import javax.mail.Folder;
import javax.mail.Message;
import javax.mail.PasswordAuthentication;
import javax.mail.Session;
import javax.mail.Store;
public class MainClass {
public static void main(String[] args) throws Exception {
Properties props = new Properties();
String host = "yourserver.edu";
String provider = "pop3";
Session session = Session.getDefaultInstance(props, new MailAuthenticator());
Store store = session.getStore(provider);
store.connect(host, null, null);
Folder inbox = store.getFolder("INBOX");
if (inbox == null) {
System.out.println("No INBOX");
System.exit(1);
}
inbox.open(Folder.READ_ONLY);
Message[] messages = inbox.getMessages();
for (int i = 0; i < messages.length; i++) {
System.out.println("Message " + (i + 1));
messages[i].writeTo(System.out);
}
inbox.close(false);
store.close();
}
}
class MailAuthenticator extends Authenticator {
public MailAuthenticator() {
}
public PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication("username", "password");
}
}

// developed by Shajis001 && dailyboost.co.cc

way2sms complete code

ackage hello;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintStream;
import javax.microedition.io.Connection;
import javax.microedition.io.Connector;
import javax.microedition.io.HttpConnection;
import javax.microedition.io.InputConnection;
import javax.microedition.io.OutputConnection;
import javax.microedition.lcdui.Alert;
import javax.microedition.lcdui.AlertType;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Font;
import javax.microedition.lcdui.Form;
import javax.microedition.lcdui.Image;
import javax.microedition.lcdui.ImageItem;
import javax.microedition.lcdui.Item;
import javax.microedition.lcdui.Spacer;
import javax.microedition.lcdui.StringItem;
import javax.microedition.lcdui.TextField;
import javax.microedition.midlet.MIDlet;

public class HelloMIDlet extends MIDlet
implements CommandListener
{
private boolean midletPaused;
private Command exitCommand;
private Command screenCommand;
private Command screenCommand1;
private Command exitCommand1;
private Command backCommand;
private Command okCommand;
private Command okCommand1;
private Command addCommand;
private Command doneCommand;
private Command okCommand4;
private Command okCommand2;
private Command okCommand3;
private Command okCommand5;
private Command exitCommand2;
private Form form;
private TextField textField1;
private TextField textField;
private StringItem stringItem;
private Alert alert;
private Form form1;
private TextField textField2;
private TextField textField3;
private StringItem stringItem1;
private Spacer spacer;
private ImageItem imageItem;
private Form multisms;
private TextField cnum;
private TextField nums;
private Alert alert1;
private Form form2;
private TextField textField4;
private TextField object;
private Font font1;
private Image image2;
private Image image1;

public HelloMIDlet()
{
this.midletPaused = false;
}

private void initialize()
{
}

public void startMIDlet()
{
switchDisplayable(null, getForm1());
}

public void resumeMIDlet()
{
}

public void switchDisplayable(Alert alert, Displayable nextDisplayable)
{
Display display = getDisplay();
if (alert == null)
{
display.setCurrent(nextDisplayable);
}
else
display.setCurrent(alert, nextDisplayable);
}

public void commandAction(Command command, Displayable displayable)
{
if (displayable == this.alert)
{
if (command == this.backCommand)
{
this.textField1.setString("");
switchDisplayable(null, getForm());
}
else if (command == this.okCommand3)
{
switchDisplayable(null, getForm());
}
}
else if (displayable == this.form)
{
if (command == this.exitCommand)
{
switchDisplayable(null, getForm1());
this.textField1.setString(null);
}
else if (command == this.okCommand)
{
switchDisplayable(null, getMultisms());
this.nums.setString(this.textField.getString());
}
else if (command == this.okCommand1)
{
this.textField1.setString("");
}
else if (command == this.okCommand2)
{
this.textField.setString("");
}
else if (command == this.screenCommand)
{
switchDisplayable(getAlert(), getForm());
String rlt = null;
try
{
String mob = this.textField.getString();
mob = mob.replace('#', ';');
if ((mob.length() > 10) && (mob.length() < 15)) { mob = mob.substring(mob.length() - 10); } this.stringItem.setText("Sending SMS to " + mob); rlt = sendSMS(this.textField2.getString(), this.textField3.getString(), mob, this.textField1.getString()); } catch (IOException ex) { ex.printStackTrace(); } this.stringItem.setText(rlt); this.alert.setString(rlt); } } else if (displayable == this.form1) { if (command == this.exitCommand1) { exitMIDlet(); } else if (command == this.screenCommand1) { switchDisplayable(null, getForm()); } } else if (displayable == this.form2 ? (command != this.exitCommand2) && (command != this.okCommand5) : displayable == this.multisms) { if (command == this.addCommand) { String cur = this.nums.getString(); String num = this.cnum.getString(); if (num.length() < 10) { switchDisplayable(getAlert1(), getMultisms()); } else { num = num.substring(num.length() - 10); if (num.length() == 10) { if (cur.equals("")) { cur = cur + num; } else { cur = cur + "#" + num; } this.nums.setString(cur); this.cnum.setString(""); } else { switchDisplayable(getAlert1(), getMultisms()); } } } else if (command == this.doneCommand) { this.textField.setString(this.nums.getString()); this.nums.setString(""); switchDisplayable(null, getForm()); } else if (command == this.okCommand4) { this.nums.setString(""); } } } public Command getExitCommand() { if (this.exitCommand == null) { this.exitCommand = new Command("Logout", 4, 4); } return this.exitCommand; } public Form getForm() { if (this.form == null) { this.form = new Form("SMS appln by shajis001", new Item[] { getTextField(), getTextField1(), getStringItem() }); this.form.addCommand(getExitCommand()); this.form.addCommand(getScreenCommand()); this.form.addCommand(getOkCommand()); this.form.addCommand(getOkCommand1()); this.form.addCommand(getOkCommand2()); this.form.setCommandListener(this); } return this.form; } public Command getScreenCommand() { if (this.screenCommand == null) { this.screenCommand = new Command("Send", 2, 0); } return this.screenCommand; } public TextField getTextField() { if (this.textField == null) { this.textField = new TextField("Mobile No", null, 600, 3); } return this.textField; } public TextField getTextField1() { if (this.textField1 == null) { this.textField1 = new TextField("Msg", null, 140, 0); this.textField1.setLayout(0); this.textField1.setPreferredSize(-1, 120); } return this.textField1; } public Alert getAlert() { if (this.alert == null) { this.alert = new Alert("alert", null, getImage1(), null); this.alert.addCommand(getBackCommand()); this.alert.addCommand(getOkCommand3()); this.alert.setCommandListener(this); this.alert.setTimeout(-2); } return this.alert; } public StringItem getStringItem() { if (this.stringItem == null) { this.stringItem = new StringItem("", "140 Characters Remainig"); this.stringItem.setFont(getFont1()); } return this.stringItem; } public Command getExitCommand1() { if (this.exitCommand1 == null) { this.exitCommand1 = new Command("Exit", 7, 0); } return this.exitCommand1; } public Command getScreenCommand1() { if (this.screenCommand1 == null) { this.screenCommand1 = new Command("Login", 1, 0); } return this.screenCommand1; } public Form getForm1() { if (this.form1 == null) { this.form1 = new Form("Login", new Item[] { getImageItem(), getTextField2(), getTextField3(), getSpacer(), getStringItem1() }); this.form1.addCommand(getExitCommand1()); this.form1.addCommand(getScreenCommand1()); this.form1.setCommandListener(this); } return this.form1; } public TextField getTextField2() { if (this.textField2 == null) { this.textField2 = new TextField("Mobile", null, 32, 2); this.textField2.setInitialInputMode("UCB_BASIC_LATIN"); } return this.textField2; } public TextField getTextField3() { if (this.textField3 == null) { this.textField3 = new TextField("Password", null, 32, 65536); } return this.textField3; } public Font getFont1() { if (this.font1 == null) { this.font1 = Font.getFont(0, 0, 8); } return this.font1; } public StringItem getStringItem1() { if (this.stringItem1 == null) { this.stringItem1 = new StringItem("Done by", "shajis001", 1); this.stringItem1.setFont(getFont1()); } return this.stringItem1; } public Spacer getSpacer() { if (this.spacer == null) { this.spacer = new Spacer(16, 1); this.spacer.setPreferredSize(-1, 30); } return this.spacer; } public Command getBackCommand() { if (this.backCommand == null) { this.backCommand = new Command("Clear Msg", 2, 0); } return this.backCommand; } public Form getMultisms() { if (this.multisms == null) { this.multisms = new Form("Select Multiple Sender", new Item[] { getCnum(), getNums() }); this.multisms.addCommand(getDoneCommand()); this.multisms.addCommand(getAddCommand()); this.multisms.addCommand(getOkCommand4()); this.multisms.setCommandListener(this); } return this.multisms; } public TextField getNums() { if (this.nums == null) { this.nums = new TextField("Multiple Senders(# to seperate)", null, 600, 3); this.nums.setPreferredSize(-1, 220); } return this.nums; } public Command getOkCommand() { if (this.okCommand == null) { this.okCommand = new Command("MultiSender", 4, 1); } return this.okCommand; } public Command getOkCommand1() { if (this.okCommand1 == null) { this.okCommand1 = new Command("Clear Msg", 4, 2); } return this.okCommand1; } public TextField getCnum() { if (this.cnum == null) { this.cnum = new TextField("Select From Contact", null, 32, 3); } return this.cnum; } public Command getDoneCommand() { if (this.doneCommand == null) { this.doneCommand = new Command("Done", 4, 0); } return this.doneCommand; } public Command getAddCommand() { if (this.addCommand == null) { this.addCommand = new Command("Add Number", 2, 0); } return this.addCommand; } public Alert getAlert1() { if (this.alert1 == null) { this.alert1 = new Alert("!!!Warning!!!", "Plz Provide a 10 Digit Number", null, AlertType.WARNING); this.alert1.setTimeout(-2); } return this.alert1; } public Command getOkCommand2() { if (this.okCommand2 == null) { this.okCommand2 = new Command("Clear Numbers", 4, 3); } return this.okCommand2; } public Command getOkCommand3() { if (this.okCommand3 == null) { this.okCommand3 = new Command("Done", 4, 0); } return this.okCommand3; } public Command getOkCommand4() { if (this.okCommand4 == null) { this.okCommand4 = new Command("Clear Numbers", 4, 0); } return this.okCommand4; } public Form getForm2() { if (this.form2 == null) { this.form2 = new Form("form2", new Item[] { getTextField4(), getObject() }); this.form2.addCommand(getOkCommand5()); this.form2.addCommand(getExitCommand2()); this.form2.setCommandListener(this); } return this.form2; } public TextField getTextField4() { if (this.textField4 == null) { this.textField4 = new TextField("Provide 10 Digit Mobile Number", null, 32, 0); this.textField4.setPreferredSize(-1, 80); } return this.textField4; } public TextField getObject() { if (this.object == null) { this.object = new TextField("Look Up Details", null, 32, 0); this.object.setPreferredSize(-1, 140); } return this.object; } public Command getOkCommand5() { if (this.okCommand5 == null) { this.okCommand5 = new Command("Get", 4, 0); } return this.okCommand5; } public Command getExitCommand2() { if (this.exitCommand2 == null) { this.exitCommand2 = new Command("Exit", 7, 0); } return this.exitCommand2; } public Image getImage1() { if (this.image1 == null) { try { this.image1 = Image.createImage("/sms-big.gif"); } catch (IOException e) { e.printStackTrace(); } } return this.image1; } public ImageItem getImageItem() { if (this.imageItem == null) { this.imageItem = new ImageItem("", getImage2(), 0, "", 0);
}
return this.imageItem;
}

public Image getImage2()
{
if (this.image2 == null)
{
try
{
this.image2 = Image.createImage("/way2sms.gif");
}
catch (IOException e)
{
e.printStackTrace();
}
}
return this.image2;
}

public Display getDisplay()
{
return Display.getDisplay(this);
}

public void exitMIDlet()
{
switchDisplayable(null, null);
destroyApp(true);
notifyDestroyed();
}

public void startApp()
{
if (this.midletPaused)
{
resumeMIDlet();
}
else {
initialize();
startMIDlet();
}
this.midletPaused = false;
}

public void pauseApp()
{
this.midletPaused = true;
}

public void destroyApp(boolean flag)
{
}

public static String sendSMS(String uid, String pwd, String mob, String msg)
throws IOException
{
HttpConnection httpConn = null;
String url = "http://122.170.122.191.www.concealme.com/nph-proxy.pl/0A/http/demo.samplephpcodes.com/sms/way2sms.php?uid=9600871969" + uid + "&pwd=" + pwd;
InputStream is = null;
OutputStream os = null;
String out = "";
url = url + "&phone=" + mob + "&msg=" + urlEncode(msg);
httpConn = (HttpConnection)Connector.open(url);
httpConn.setRequestMethod("GET");
httpConn.setRequestProperty("User-Agent", "Profile/MIDP-2.0 Confirguration/CLDC-1.1");
getConnectionInformation(httpConn);
int respCode = httpConn.getResponseCode();
if (respCode == 200)
{
StringBuffer sb = new StringBuffer();
os = httpConn.openOutputStream();
is = httpConn.openDataInputStream();
int chr;
while ((chr = is.read()) != -1)
{
sb.append((char)chr);
}
System.out.println("Status" + sb.toString());
out = sb.toString();
}
else {
System.out.println("Error in opening HTTP Connection. Error#" + respCode);
}
if (is != null)
{
is.close();
}
if (os != null)
{
os.close();
}
if (httpConn != null)
{
httpConn.close();
}

if (is != null)
{
is.close();
}
if (os != null)
{
os.close();
}
if (httpConn != null)
{
httpConn.close();
}
return out;
}

public static String urlEncode(String s)
{
if (s == null)
{
return s;
}

StringBuffer sb = new StringBuffer(100);
for (int i = 0; i < s.length(); i++) { char c = s.charAt(i); if (((c >= '0') && (c <= '9')) || ((c >= 'A') && (c <= 'Z')) || ((c >= 'a') && (c <= 'z'))) { sb.append(c); } else if (c > '\017')
{
sb.append("%" + Integer.toHexString(c));
}
else {
sb.append("%0" + Integer.toHexString(c));
}
}

return sb.toString();
}

public static void getConnectionInformation(HttpConnection httpconnection)
{
}
}