Showing posts with label In Java. Show all posts
Showing posts with label In Java. Show all posts

Tuesday, September 9, 2008 | | 0 comments

J2ME - A quick introduction

J2ME or Java 2 micro edition (Also known as Java 2 Mobile Edition) is the version of Java for micro devices. The term micro devices include Mobiles, Handhelds, Palm PCs, embedded systems or even smart cards. So Java is like this J2SE - J2EE - J2ME each with its own specific uses.

J2ME combines a less resourceful JVM and a small set of JAVA apis oriented and designed specifically to develop mobile application for mobile devices. J2ME applications are also called MIDlets, like applets in J2SE and servelets in J2EE (similarity is mostly in name only).


Sunday, September 7, 2008 | | 0 comments

Why implementing runnable is better than extending thread?

We all know that there is two ways to implement threading in Java. And everyone say that implementing runnable is better than extending thread. Why is it so? Simple answer...A Java class can extend only one class( Hybrid or Hierarchical inheritance is not supported) but it can implement any number of interfaces. Thus if we extend Thread in a class which require to be an applet or form, it is not possible.
So always implement runnable.

Friday, September 5, 2008 | | 0 comments

Simplest network Program in Java

Before going to a GUI network program, I decided to write a simple network program in Java. Wrote it and code is given below. A network program in Java can not be simpler than this. basically this program has two files.
  • s.java
  • c.java
s and c stands for server and client respectively. client sends a piece of text "This is the simplest text" to server. Server displays it. Thats all. Simple Huh!

s.java:


import java.net.*;
import java.io.*;

class s
{
ServerSocket servSoc=null;
DataInputStream din = null;
String s;
Socket soc;

s()
{
try{
servSoc=new ServerSocket(2008);
soc=servSoc.accept();
din=new DataInputStream(soc.getInputStream());

while(true)
{
s=din.readLine();
System.out.println(s);

}
}
catch(Exception e){}
}
public static void main(String ars[])
{
s s1=new s();

}
}



c.java:


import java.net.*;
import java.io.*;

class c
{
Socket soc = null;
PrintWriter pr=null;

c()
{
try{
soc=new Socket("localhost",2008);
pr=new PrintWriter(soc.getOutputStream(),true);
pr.println("This is the simplest text");
}
catch(Exception e)
{}

}
public static void main(String args[])
{
c c1=new c();
}
}


Saturday, August 30, 2008 | | 0 comments

Packages in Java

A package is a collection of classes. There are inbuilt packages and you can also build package of your own. In fact, whatever program you build belong to a package(It was a new information for me). If you do not manually specify a package name, it belong to a nameless package. It is recommended only for small test programs sor simple applications. All major works should use a package. We will do too!!!

You can learn more about packages here
Sun tutorial on Java PAckages

| | 0 comments

Mini project in Java

Hi, I'm Vishnu Prathish from College of Engineering Trivandrum. We have to submit a mini project for our 5th semester for evaluation. We mean to do it in Java though I'm not well versed with it. So I started this blog to keep track the course in which I'm learning Java and eventually we develop our project.

I begin here....