Socket example using Java 5

Last year I posted 4 programs that provided a simple client server using both stream sockets and NIO. I decided as an exercise in using Java 5 to port that code and try to use as many of the new features as possible. The following code is very long and does what all the previous example programs did. In replies do not repost the whole of this message.
It provides a simple chat like client and server. The user can request either a stream connection or a NIO connection or provide one of their own.
//========================== MsgSwitch.java ===========================//
package pkwnet.msgswitch;
import java.util.logging.Logger;
import java.util.logging.Level;
import java.util.logging.Handler;
* main class for message switch
* command line arguments are
* -p port number for server
* -s run server
* -a server ip address including port for client
* -i idle timer in seconds
* -n use NIO
* -c specify connection class
public class MsgSwitch {
    static private int errors = 0;
    static private String address = "127.0.0.1:6060";
    static private String connectionClass = "pkwnet.msgswitch.StreamConnection";
    static public void main(String [] args) {
        int port = 6060;
        int idleTime = 600;
        boolean server = false;
        boolean nio = false;
        Logger logger = Logger.getLogger("msgswitch");
        for(String arg : args) {
            if(arg.startsWith("-a")) {
                address = arg.substring(2);
            } else if(arg.startsWith("-p")) {
                port = argToInt(arg);
                server = true;
            } else if(arg.startsWith("-i")) {
                idleTime = argToInt(arg);
            } else if (arg.startsWith("-s")) {
                server = true;
            } else if (arg.startsWith("-c")) {
                connectionClass = arg.substring(2);
            } else if (arg.startsWith("-n")) {
                connectionClass = "pkwnet.msgswitch.NIOConnection";
            } else {
                String err = "unknown argument=" + arg;
                logger.severe(err);
                System.err.println(err);
                errors++;
        if (errors == 0) {
            if (server) {
                new Server().listen(port,idleTime, nio);
            } else {
                new Client().start(address, nio);
        } else {
            fail(errors + " errors encountered", null);
    static private int argToInt(String arg) {
        int val = 0;
        try {
            val = Integer.parseInt(arg.substring(2));
        } catch (NumberFormatException e) {
            String err = "invalid argument format: " + arg;
            Logger.getLogger("msgswitch").severe(err);
            System.err.println(err);
            errors++;
        return val;
    static public void fail(String err, Throwable e) {
        String msg = "Operation terminated: " + err;
        Logger.getLogger("msgswitch").log(Level.SEVERE, msg, e);
        System.err.println(msg);
        System.exit(12);
    static public Connection getConnection() {
        Connection conn = null;
        try {
            conn = (Connection) Class.forName(connectionClass).newInstance();
        } catch (Exception e) {
            fail ("connection class error", e);
        return conn;
    static public void logCaller(Logger logger, Level level) {
        String text = "CALLED";
        if (logger.isLoggable(level)) {
            try {
                throw new Exception("logging stack");
            } catch (Exception e) {
                StackTraceElement [] st = e.getStackTrace();
                if (st.length > 1) {
                    text += formatElement(st[1]);
                if (st.length >2) {
                    text += formatElement(st[2]);
            logger.log(level, text);
    static private String formatElement(StackTraceElement ste) {
        return "\n    " + ste.getClassName() + "." + ste.getMethodName()
            + "(" + ste.getFileName() + ":" + ste.getLineNumber() + ")";
//================= Client.java =============================================//
package pkwnet.msgswitch;
* a simple Swing chat GUI using Java 5 and sockets.
* @author PKWooster
* @version 1.0 August 31,2005
import javax.swing.JFrame;
import javax.swing.JTextField;
import javax.swing.JTextArea;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JMenu;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JDialog;
import javax.swing.SwingUtilities;
import java.awt.Container;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.BorderLayout;
import static java.awt.BorderLayout.*;
client GUI class
public class Client extends JFrame implements ConnectionListener {
     // swing GUI components
     private JTextField userText = new JTextField(40);
     private JTextArea sessionLog = new JTextArea(24,40);
     private JTextField statusText = new JTextField(40);
     private JPanel outPanel = new JPanel();
     private JScrollPane sessionLogScroll = new JScrollPane(sessionLog);
     private JMenuBar menuBar = new JMenuBar();
     private JMenuItem startItem = new JMenuItem("Start");
     private JMenuItem hostItem = new JMenuItem("Host");
     private JMenuItem aboutItem = new JMenuItem("About");
     private JMenuItem abortItem = new JMenuItem("Abort");
     private JMenuItem exitItem = new JMenuItem("Exit");
     private JMenu fileMenu = new JMenu("File");
     private JMenu helpMenu = new JMenu("Help");
     private Container cp;
     private String address;
    private Connection connection;
    private boolean sendReady = false;
    private boolean nio = false;
     Client() {
    public void start(String address, boolean nio) {
        this.address = address;
        this.nio = nio;
        SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                runClient();
    private void runClient() {   
        connection = MsgSwitch.getConnection();
        connection.addConnectionListener(this);
          buildMenu();
          cp = getContentPane();
          sessionLog.setEditable(false);
          outPanel.add(new JLabel("Send: "));
          outPanel.add(userText);
          // enter on userText causes transmit
          userText.addActionListener(new ActionListener(){
               public void actionPerformed(ActionEvent evt){userTyped(evt);}
          cp.setLayout(new BorderLayout());
          cp.add(outPanel,NORTH);
          cp.add(sessionLogScroll,CENTER);
          cp.add(statusText,SOUTH);
          setStatus("Closed");
          addWindowListener(new WindowAdapter() {
            public void windowClosing(WindowEvent evt) {
                mnuExit();
          pack();
        setVisible(true);
* attempt to send the contents of the user text field
    private void userTyped(ActionEvent evt) {
        if (sendReady) {
            String txt = evt.getActionCommand()+"\n";
            userText.setText("");
            toSessionLog("> ", txt);
            sendReady = false;
            connection.send(txt);
* append text to the session log
     private void toSessionLog(String prefix, String txt) {
          sessionLog.append(prefix + txt);
          sessionLog.setCaretPosition(sessionLog.getDocument().getLength() ); // force last line visible
* build the standard menu bar
     private void buildMenu()
          JMenuItem item;
          // file menu
          startItem.addActionListener(new ActionListener()
          {public void actionPerformed(ActionEvent e){mnuStart();}});
          fileMenu.add(startItem);
          hostItem.addActionListener(new ActionListener()
          {public void actionPerformed(ActionEvent e){mnuHost();}});
          fileMenu.add(hostItem);
          exitItem.addActionListener(new ActionListener()
          {public void actionPerformed(ActionEvent e){mnuExit();}});
          fileMenu.add(exitItem);
          menuBar.add(fileMenu);
          helpMenu.add(aboutItem);
          aboutItem.addActionListener(new ActionListener()
          {public void actionPerformed(ActionEvent e){mnuAbout();}});
          menuBar.add(helpMenu);
          setJMenuBar(menuBar);
* start and stop communications from start menu
     private void mnuStart() {
        if(connection.getState() ==  Connection.State.CLOSED) {
            connection.connect(address);
        } else {
            connection.disconnect();
*  prompt user for host in form address:port
    private void mnuHost() {
          String txt = JOptionPane.showInputDialog("Enter host address:port", connection.getAddress());
          if (txt == null)return;
        address = txt;
     private void mnuAbout() {
          JDialog dialog = new JDialog(this, "About Client");
          JTextField text = new JTextField("Simple character client");
        dialog.getContentPane().add(text);
        dialog.pack();
        dialog.setVisible(true);
     // exit menu
     private void mnuExit() {
        exit();
    private void exit() {
          connection.disconnect();
          System.exit(0);
     private void setStatus(String st) {
        statusText.setText(st);
     private void setStatus(Connection.State state) {
        switch(state) {
            case OPENED:
                startItem.setText("Stop");
                setStatus("Connected to "+address);
                break;
            case CLOSED:
                startItem.setText("Start");
                setStatus("Disconnected");
                break;
            case OPENING:
                setStatus("Connecting to "+address);
                startItem.setText("Abort");
                break;
            case CLOSING:
                setStatus("Disconnecting from "+address);
                startItem.setText("Abort");
                break;
    public void stateChanged(final ConnectionEvent event) {
        SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                setStatus(event.getState());
    public void dataAvailable(final ConnectionEvent event) {
        SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                setStatus(event.getState());
                String txt = event.getData();
                if (txt == null) {
                    txt = "$null$";
                toSessionLog("< ", txt + "\n");   
    public void sendAllowed(final ConnectionEvent event) {
        SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                setStatus(event.getState());
                sendReady = true;
    public void accept(ConnectionEvent event) {
//========================== Server.java ===============================//
package pkwnet.msgswitch;
import java.io.*;
import java.net.*;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
* a simple message switch using stream based socket i/o
* a very simple text message switching program
* user commands start with $ and consist of blank seperated arguments
* other lines sent by the user are forwarded
* $on nickname targets
*    sign on as nickname, sending to targets
* $to targets
*    change target list, reports current value
* $list nicknames
*    list status of specified nicknames
* $list
*    list all connected users
* $off
*    sign off
* @author PKWooster
* @version 1.0 September 1, 2005
public class Server {
    private ConcurrentHashMap<String, User> perUser = new ConcurrentHashMap<String,User>();
    private Timer idleTimer;
    private Connection conn;
    public void listen(int port, final int idleTime, boolean nio) {
        idleTimer = new Timer();
        idleTimer.scheduleAtFixedRate(new TimerTask(){public void run(){oneSec();}},0,1000);
        conn = MsgSwitch.getConnection();
        conn.addConnectionListener(new ConnectionListener() {
            public void stateChanged(ConnectionEvent event) {
            public void dataAvailable(ConnectionEvent event) {
            public void sendAllowed(ConnectionEvent event) {
            public void accept(ConnectionEvent event) {
                Connection uconn = event.getConnection();
                new User(uconn, perUser, idleTime);
        conn.listen(port);
        idleTimer.cancel();
    private void oneSec() {
        Collection<User> uc = perUser.values();
        for(User u : uc) {
            u.oneSec();
//================= User.java  ==============================================//
package pkwnet.msgswitch;
import java.io.*;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.logging.Logger;
import java.util.logging.Level;
* defines the processing for a message switch user
* @author PKWooster
* @version 1.0 June 15,2004
public class User implements ConnectionListener {
    private ConcurrentHashMap<String, User> perUser;
    private String name;
    private String address;
    private boolean signedOn = false;
    private String[] targets;
    private AtomicInteger remainingTime;
    private int idleTime;
    Connection conn;
    Logger logger;
  * construct a user, link it to its connection and put it in the perUser table
    User(Connection conn, ConcurrentHashMap<String,User>p, int idle) {
        this.conn = conn;
        logger = Logger.getLogger("msgswitch.user");
        conn.addConnectionListener(this);
        address = conn.getAddress();
        logger.info("creating user " + address);
        perUser = p;
        idleTime = idle;
        remainingTime = new AtomicInteger(idleTime);
        rename(address);
        targets = new String[0];
* process state changes
    public void stateChanged(ConnectionEvent event) {
        if(event.getState() == Connection.State.CLOSED) {
            close(false);
* data is available, process commands and forward other data.
    public void dataAvailable(ConnectionEvent event) {
        String msg = event.getData();
        if (msg.startsWith("$")) {
            doCommand(msg);
        } else {
            forward(msg);
        remainingTime.set(idleTime);
* do nothing for sendAllowed events
    public void sendAllowed(ConnectionEvent event) {
* do nothing for accept events
    public void accept(ConnectionEvent event) {
* called once per second by the server main thread.
    public void oneSec() {
        if(idleTime != 0 && 1 > remainingTime.decrementAndGet()) {
            close(true);
* send a message
    private void send(String msg) {
        conn.send(msg);
        remainingTime.set(idleTime);
* forward data messages to other users
* @param txt the message to send
    private void forward(String txt) {
        txt = name+": "+txt + "\n";
        if(0 < targets.length) {
            for(String target :targets) {
                User user = perUser.get(target);
                if(user != null) {
                    user.send(txt);
        } else {
            for (User user : perUser.values()) {
                if (user != this) {
                    user.send(txt);
* execute command messages, commands start with a $
* and contain arguments delimited by white space.
* @param command the command string
    private void doCommand(String command) {
        boolean good = false;
        command = command.substring(1).trim();
        if(command.length() > 0) {
            String [] args = command.split("\\s+");
            if(args[0].equals("on")) {
                good = signOn(args);
            } else if(args[0].equals("off")) {
                good = signOff(args);
            } else if(args[0].equals("list")) {
                good = listUsers(args);
            } else if(args[0].equals("to")) {
                good = setTargets(args,1);
            } else if(args[0].equals("idle")) {
                good = setIdle(args);
            if(!good) {
                send("invalid command=" + command + "\n");
* sign on command
    private boolean signOn(String [] args) {
        boolean good = false;
        if(args.length >1) {
            String nm = args[1];
            logger.info("signing on as: " + nm);
            if(rename(nm)) {
                conn.setName(name);
                send("Signed on as " + name + "\n");
                signedOn = true;
                good = true;
                setTargets(args,2);
            } else {
                send("name="+nm+" already signed on\n");
        return good;
* set forwarding targets
    private boolean setTargets(String [] args, int start) {
        if(start < args.length) {
            targets = new String[args.length-start];
            System.arraycopy(args, start, targets, 0, targets.length);
        String str = "to=";
        for(String target : targets) {
            str += (target + " ");
        send(str+"\n");
        return true;
* set idle timeout
    private boolean setIdle(String[] args) {
        try {
            idleTime = new Integer(args[1]).intValue();
            remainingTime.set(idleTime);
            send("idle time set to "+idleTime+"\r\n");
            return true;
        } catch(NumberFormatException exc) {
            return false;
* sign off
    private boolean signOff(String [] args) {
        close(true);
        return true;
* list connected users
    private boolean listUsers(String [] args) {
        TreeSet<String> allUsers = new TreeSet<String>(perUser.keySet());
        HashSet<String> t = new HashSet<String>(Arrays.asList(targets));
        LinkedList<String> users;
        String response = "On,Target,Nickname\n";
        if(args.length < 2) {
            users = new LinkedList<String>(allUsers);
        } else {
            users = new LinkedList<String>();
            for (int i = 1; i < args.length; i++) {
                users.add(args);
for(String username : users) {
if(username.equals(name)) {
response += "*,";
} else {
response += (allUsers.contains(username) ? "y," : "n,");
response += (t.contains(username) ? "y," : "n,");
response += (username + "\n");
send(response);
return true;
* rename this user, first we attempt to add the new name then we remove
* the old one. Both names will be registered for a short while.
* @param newname the new name for this user
* @return true if the rename was successful
private boolean rename(String newname) {
boolean b = false;
logger.info("rename name="+name+" newname="+newname);
if (name != null && name.equals(newname)) {
b = true;
} else if (null == perUser.putIfAbsent(newname, this)) {
if (name != null) {
perUser.remove(name);
name = newname;
b = true;
return b;
* delete from perUser and close our connection
private void close(boolean disconnect) {
logger.info("closing user "+name);
perUser.remove(name);
if (disconnect) {
conn.disconnect();
//====================== Connection.java ===============================//
package pkwnet.msgswitch;
import java.util.HashSet;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.logging.Logger;
import java.util.logging.Level;
public abstract class Connection {
public enum State {CLOSED, OPENING, OPENED, CLOSING}
private HashSet<ConnectionListener> listeners = new HashSet<ConnectionListener>();
private State state = State.CLOSED;
private String host = "127.0.0.1";
private int port = 6060;
private String name = "unconnected";
public Connection() {
public abstract void listen(int port);
public abstract void connect(String address);
public abstract void disconnect();
public abstract void send(String message);
public void addConnectionListener(ConnectionListener listener) {
listeners.add(listener);
public void removeConnectionListener(ConnectionListener listener) {
listeners.remove(listener);
protected void fireDataAvailable(String data) {
for (ConnectionListener listener : listeners) {
listener.dataAvailable(new ConnectionEvent(this, state, data));
private void fireStateChanged() {
for (ConnectionListener listener : listeners) {
listener.stateChanged(new ConnectionEvent(this, state));
protected void fireSendAllowed() {
for (ConnectionListener listener : listeners) {
listener.sendAllowed(new ConnectionEvent(this, state));
protected void fireAccept(Connection conn) {
for (ConnectionListener listener : listeners) {
listener.accept(new ConnectionEvent(this, conn));
protected void setState(State state) {
if (this.state != state) {
this.state = state;
fireStateChanged();
public State getState() {
return state;
protected void setAddress(String address) {
          int n = address.indexOf(':');
          String pt = null;
setName(address);
if(n == 0) {
               host = "127.0.0.1";
               pt = address.substring(1);
          else if(n < 0) {
               host = address;
               port = 5050;
          } else {
host = address.substring(0,n);
               pt = address.substring(n+1);
if (pt != null) {
try {
port = Integer.parseInt(pt);
} catch (NumberFormatException e) {
port = -1;
public String getName() {
return name;
public void setName(String value) {
name = value;
public String getAddress() {
return host + ":" + port;
public String getHost() {
return host;
public void setPort(int value) {
port = value;
public int getPort() {
return port;
//=================== ConnectionEvent.java ================================//
package pkwnet.msgswitch;
public class ConnectionEvent extends java.util.EventObject {
private final String data;
private final Connection.State state;
private final Connection conn;
public ConnectionEvent(Object source, Connection.State state, String data, Connection conn) {
super(source);
this.state = state;
this.data = data;
this.conn = conn;
public ConnectionEvent(Object source, Connection.State state, String data) {
this(source, state, data, null);
public ConnectionEvent(Object source, Connection.State state) {
this(source, state, null, null);
public ConnectionEvent(Object source, Connection conn) {
this(source, conn.getState(), null, conn);
public Connection.State getState() {
return state;
public String getData() {
return data;
public Connection getConnection() {
return conn;
//============================ ConnectionListener.java ===================//
package pkwnet.msgswitch;
public interface ConnectionListener extends java.util.EventListener {
public void stateChanged(ConnectionEvent event);
public void dataAvailable(ConnectionEvent event);
public void sendAllowed(ConnectionEvent event);
public void accept(ConnectionEvent event);
//============================ StreamConnection.java ===================//
package pkwnet.msgswitch;
import java.net.Socket;
import java.net.ServerSocket;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.IOException;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.logging.Logger;
import java.util.logging.Level;
* provides stream socket i/o of character strings
* @author PKWooster
* @version 1.0 September 1, 2005
public class StreamConnection extends Connection {
private Socket sock;
private BufferedReader in;
private BufferedWriter out;
private Thread recvThread = null;
private Thread sendThread = null;
protected LinkedBlockingQueue<String> sendQ;
Logger logger;
public StreamConnection() {
super();
logger = Logger.getLogger("msgswitch.stream");
sendQ = new LinkedBlockingQueue<String>();
* open a socket and start i/o threads
public void connect(String ipAddress) {
setAddress(ipAddress);
try {
sock = new Socket(getHost(), getPort());
connect(sock);
} catch (IOException e) {
logger.log(Level.SEVERE, "Connection failed to=" + ipAddress, e);
private void connect(Socket sock) {
this.sock = sock;
String ipAddress = getAddress();
try {
in = new BufferedReader(new InputStreamReader(sock.getInputStream()));
out = new BufferedWriter(new OutputStreamWriter(sock.getOutputStream()));
recvThread = new Thread(new Runnable() {
public void run() {
doRecv();
},"Recv." + getName());
sendThread = new Thread(new Runnable() {
public void run() {
doSend();
},"Send."+getName());
sendThread.start();
recvThread.start();
setState(State.OPENED);
} catch(IOException e) {
logger.log(Level.SEVERE, "Connection failed to="+ipAddress, e);
public void listen(int port) {       
StreamConnection sconn;
setPort(port);
try {
ServerSocket ss = new ServerSocket(port);
while(true) {
Socket us = ss.accept();
sconn = new StreamConnection();
String ipAddress = us.getInetAddress() + ":" + us.getPort();
sconn.setAddress(ipAddress);
sconn.connect(us);
fireAccept(sconn);
} catch(Exception e) {
logger.log(Level.SEVERE, "listen failed", e);
* close the socket connection
public void disconnect() {
logger.fine("disconnect sock=" + sock + " state="+ getState());
if(getState() == State.OPENED) {
setState(State.CLOSING);
try {
sock.shutdownOutput();
} catch(IOException ie) {
logger.log(Level.SEVERE, "showdown failed", ie);
} else if(getState() != State.CLOSED) {
try {
sock.close();
} catch(Exception e) {
logger.log(Level.SEVERE, "close failed", e);
if (sendThread.isAlive()) {
sendThread.interrupt();
sendQ.clear();
setState(State.CLOSED);
public void send(String message) {
if (getState() == State.OPENED) {
try {
sendQ.put(message);
} catch(InterruptedException e) {
logger.log(Level.SEVERE, "sendQ put interrupted", e);
setState(State.CLOSING);
disconnect();
* sets the public name of this connection
public void setName(String name) {
super.setName(name);
if (sendThread != null) {
try {
recvThread.setName("recv." + name);
sendThread.setName("send." + name);
} catch(Exception e) {
logger.log(Level.SEVERE, "nameing threads failed", e);
* the main loop for the send thread
private void doSend() {
String msg;
boolean running = true;
while (running) {
if (sendQ.size() == 0) {
fireSendAllowed();
try {
msg = sendQ.take();
out.write(msg);
out.flush();
} catch(Exception e) {
if (getState() == State.OPENED) {
logger.log(Level.SEVERE, "write failed", e);
setState(State.CLOSING);
disconnect();
running = false;
* the main loop for the receive thread
private void doRecv() {
String inbuf;
while (getState() == State.OPENED) {
try {
inbuf = in.readLine();
} catch(Exception e) {
if (getState() == State.OPENED) {
logger.log(Level.SEVERE, "readline failed", e);
inbuf = null;
if(inbuf == null) {
logger.fine("null received on: " + getAdd

Here are three of them:
NIO server
NIO client
Multithreaded server
The stream based client example seems to have been deleted, probably lost in the troll wars. I also posted a new Simple multithreaded server that uses the same protocol. As the client is missing, I'll repost it.

Similar Messages

  • Need help with Socket prog using Java wireless toolkit

    Hi, I am not able to communicate between client (Palm emulator) and server (Java on computer) using Java Wireless toolkit.
    Can anyone please tell me a site that shows an example. I have seen a bunch of examples but they all run by importing com.sun.kjava which seems to have vanished into thin air. So I cannot run them. Someone please show me some lines of code that will send just one character from client Palm emulator to server. thanks.
    Syed

    hi,
    I hope that you already have the J2ME Toolkit and that your emulator works okay. In the toolkit you get several examples to show you how to program a MIDlet. One has to do with a HTTP client server connection. Also in the API documentation for the J2ME there is a Connector class that you used to set up this communication and in the description of this class it pretty thoroughly explains how to set up an HTTP protocol client.
    However, if you want to do some other kind of networking then you are pretty much out of luck, as the TCPIP socket protocol has not been fully implemented and is optional to the J2ME specifications, only the HTTP protocol is certain to be available. This means that mobile phone companies can add other networking functionality to their phone's java virtual machine if they feel like it. This is a bummer I know.
    I hope this helps.
    Cheers,
    Mark

  • Detect loss of socket connection using java.nio.channels.Selector

    I'm using the nio package to write a "proxy" type application, so I have a ServerSocketChannel listening for incoming connections from a client and then create a SocketChannel to connect to a server. Both SocketChannels are registered to the same Selector for OP_READ requests.
    All works fine, until either the client or server drops the connection. How can I detect this has happened, so my proxy app can drop the other end of the connection ?
    The Selector.select() method is not triggered by this event. I have tried using Selector.select(timeout) and then checking the status of each channel, but they still show isConnected()=true.
    Thanks,
    Phil Blake

    Please don't cross post.
    http://forum.java.sun.com/thread.jsp?thread=184411&forum=4&message=587874

  • SOAP XmlParsing using java

    Hi i have to read Client request and request comes in SOAP xml file read the file and process the response convert in SOAP xml file. please provide an example using java .

    Hi Jason, did you ever architect a solution for this?

  • Polling gpib/enet unit over tcp/ip using java

    I understand that there is a linux driver for the gpib/enet product. Since I assume this device is polled over a tcp/ip connection, do I need to do this in C, ot can I establish a socket connection using java ? If so, what is the driver for ? is it just to assign an ip address and other setup functions ?
    Thanks
    John Adams

    Hi John,
    You do not need to do this in C. In fact you can do it in just about any language. The librarys are exported to a shared object, so as long as your language can make calls to a .so, you are good to go. I am positive that java has this capability.
    Hope this helps out! If you need the driver, it is available at www.ni.com/linux.
    Best Regards,
    Aaron K.
    Application Engineer
    National Instruments

  • Connecting to http web site using java socket

    Hi,
    Sockets in Java I believe are reusable. Once created, it can be used to send a request using its input stream and get back a response using the output stream. My problem is I am trying to connect to a website using java socket but I am unable to get a response (though the same works fine I use URL and URLConnection). Can anyone tell me whats wrong? Below is the client program:
    public class HttpAdapterTest {
         public static void main(String[] args) {
              try {
                   Socket socket = new Socket("www.google.com", 80);
                   BufferedWriter out = new BufferedWriter(
                                  new OutputStreamWriter(socket.getOutputStream()));
                   out.write("GET /help/basics.html HTTP/1.1");
                   out.flush();
                   BufferedReader in = new BufferedReader(
                                            new InputStreamReader(ucon.getInputStream()));
                   String line = null;
                   while((line = in.readLine()) != null) {
                        System.out.println(line);
                   in.close();
              } catch (Exception e) {
                   e.printStackTrace();
    }

    Look at the JSSE examples. You need to setup a key store, add the jsse jars to your classpath, yadda, yadda, yadda....

  • RFC Lookup using Java Mapping program - Examples

    Dear Experts,
    I am working on a scenario which is using 1:N mapping. For deciding the target message I have to use RFC Lookup to call the backend ERP system and there are 2 ERP systems involved in this integration. As I am using Java Mapping and never did a RFC Lookup in Java. I kindly request you to give me some examples which I could use for my RFC calls in my Java Mapping. Simple example will do.
    Client is adamant to use Java mapping, I could achieve this easily using XSLT or Graphical Mapping.
    Advance Thanks,
    Pradeep

    Hello,
    why don't you use Extended Receiver Determination Defining Extended (Dynamic) Receiver Determination - Integration Directory - SAP Library?
    What you can do is create a Message Mapping between your source message and Receivers message type. In this message mapping you can use your RFC to generate the target message.
    For example, lets say we have the function ZFM_GET_INTERFACE_INFO used to generate the List of Receivers given a source message. You could create a Message Mapping as below:
    In this case, the RFCLookup box look as below:
    The receiver determination configuration would look as follows:
    Afterwards, you will need two specific message mappings for the two ERP systems.
    Summarizing, you'll need:
    1.- A Message Mapping: Source Message to Receivers Message Type (This one uses the RFC Lookup)
    2.- A Message Mapping: Source Message to Target Message for ERP 1
    3.- A Message Mapping: Source Message to Target Message for ERP 2
    In Integration Directory you'll have 1 Receiver Determination(Source system, Target System determined Dynamically) and 2 Interface Determinations (Source System to ERP1, Source System to ERP2), etc.
    I hope you find it useful.
    Regards!

  • Whenever I use something which uses Java (for example, an online game) and then click the address bar, it seems that the address bar is disabled.

    Whenever I use something which uses Java (for example, an online game) and then click the address bar, it seems that the address bar is disabled. I cannot highlight or type in the address bar unless I interact with another program and then switch back to Firefox. When I interact with Java again, the same problem persists! Help!
    Sorry, I didn't know what category this should be under, but it's urgent.

    Perform the suggestions mentioned in the following articles:
    * [https://support.mozilla.com/en-US/kb/Template:clearCookiesCache/ Clear Cookies & Cache]
    * [[Troubleshooting extensions and themes]]
    Check and tell if its working.
    Some of your Firefox Plugins are out-dated
    * Update All your Firefox Plugins -> [https://www.mozilla.org/en-US/plugincheck/]
    * '''When Downloading Plugins Update setup files, Remove Checkmark from Downloading other Optional Softwares with your Plugins (e.g. Toolbars, McAfee, Google Chrome, etc.)'''

  • Example of using JAVA to implement location transparency

    Dear all,
    Is any example or source code show me how to using JAVA to implement location transparency?
    Thanks
    Ronnie Poon

    <frameset> should not be the child of the <body> element. It should be the child of <html> element.
    This works:
    <?xml version="1.0" encoding="UTF-8"?>
    <jsp:root version="1.2" xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html" xmlns:jsp="http://java.sun.com/JSP/Page" xmlns:ui="http://www.sun.com/web/ui">
    <jsp:directive.page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"/>
    <f:view>
    <ui:page id="page1">
    <ui:html id="html1">
    <ui:head id="head1">
    <ui:link id="link1" url="/resources/stylesheet.css"/>
    </ui:head>
    <frameset cols="30%,70%">
    <frame name="left" src="faces/Page1.jsp"/>
    <frameset rows="80%,20%">
    <frame name="top" src="faces/rightPage.jsp"/>
    <frame name="bottom" src="faces/bottomPage.jsp"/>
    </frameset>
    </frameset>
    </ui:html>
    </ui:page>
    </f:view>
    <ui:form binding="#{bean.form1}" id="form1"/>
    </jsp:root>
    thanks,
    tsc

  • Is is possible to create Socket using Java Stored Procedures/Function(Ora)?

    Hello Friends,
    Is is possible to create Socket using Java Stored Procedures/Function in Oracle?
    OR
    How I can send a message from oracle to Java Desktop Application which is working like server program?
    Please Guide !!

    J3Ganesh wrote:
    Hello Friends,
    Is is possible to create Socket using Java Stored Procedures/Function in Oracle?No, Oracle was very careful to take that feature out of the JDK provided in Oracle 10/11, but you can buy that feature back for, if I remember correctly, about 5000 dollars. (I actually raised a service request on this and then told my rep what I thought about the answer I received--some thing along the line of money grubbing so and so....)
    How I can send a message from oracle to Java Desktop Application which is working like server program?You can make a table and poll it from time to time from the Java side and write and commit what ever you want to the table. I do not know any way to send a signal from Oracle DB an external Java application--Java or PL/SQL stored procedure.

  • Accessing seured website using java URL/Socket programming

    Hi,
    I am working on an intranet search engine using java URL and Authenticator class. This is a secured web-site using SSL in http server. I am not able to access the password protected pages. Following is the code:
    URL url = new URL("https://*************");
    URLConnection connection = url.openConnection();
    PasswordAuthentication pa = Authenticator.requestPasswordAuthentication( InetAddress.getByName(connection.getURL().getHost()),
    connection.getURL().getPort(), connection.getURL().getProtocol(), null, "Basic");
    StringBuffer buf = new StringBuffer("*****************");
    buf.append(":");
    buf.append("************");
    String encoded = new sun.misc.BASE64Encoder().encode(buf.toString().getBytes());
    connection.setRequestProperty ("Authorization", "Basic" + encoded);
    InputStream content = (InputStream)connection.getInputStream();
    BufferedReader in = new BufferedReader (new InputStreamReader (content));
    String line;
    while ((line = in.readLine()) != null) {
    System.out.println(line);
    Let me know if there is any other alternative
    tnx,
    Biswajit Biswal

    Below is my first test program. I first take the home page of a website (this can be automated later) and save it to "myTest.html". Then I try to see if this page contains the keywords that a company website often has.
    Could you give your opinion on this approach?
    If this approach is fine, then any idea about the keywords to select a company website from other sites is welcome.
    import java.io.BufferedReader;
    import java.io.IOException;
    import java.io.InputStream;
    import java.io.InputStreamReader;
    import java.io.Reader;
    public class MyTest {
          * @param args
          * @throws IOException
         public static void main(String[] args) throws IOException {
              InputStream in = MyTest.class.getResourceAsStream("/myTest.html");
              Reader reader = new InputStreamReader(in, "UTF-8");
              BufferedReader bufferedReader = new BufferedReader(reader);
              String line;
              while ((line = bufferedReader.readLine()) != null) {
                   line=line.toLowerCase();
                   if (line.contains("contact us")) {
                        System.out.println("contact us: line = "+line);
                   if (line.contains("career")) {
                        System.out.println("career: line = "+line);
                   if (line.contains("company")) {
                        System.out.println("company: line = "+line);
                   if (line.contains("about us")) {
                        System.out.println("about us: line = "+line);
                   if (line.contains("product")) {
                        System.out.println("product: line = "+line);
              bufferedReader.close();
              reader.close();
    }

  • MulticastSocket Multicast socket receive error: java.lang.RuntimeException: I/O error opening JAR file from file:/D:/weblogic/mycluster/server86/tmp_deployments/ejbjar-17327.jar

    Hi,
              I need some help.
              Product=weblogic5.1.0
              Revision=(Release Level)=
              Problem Description=
              I am doing cluster of weblogic server, I have no problem to set up the
              cluster and to run servlet and EJB examples.
              However, on my command line for startcluster I got a lot of message as
              followed:
              Fri Aug 18 11:31:44 EDT 2000:<E> <MulticastSocket> Multicast socket receive
              error: java.lang.RuntimeException: I/O error opening JAR file from
              file:/D:/weblogic/mycluster/server86/tmp_deployments/ejbjar-17327.jar
              java.util.zip.ZipException: error in opening zip file
              at java.util.zip.ZipFile.open(Native Method)
              at java.util.zip.ZipFile.<init>(ZipFile.java, Compiled Code)
              at java.util.zip.ZipFile.<init>(ZipFile.java, Compiled Code)
              at weblogic.boot.ServerClassLoader.deploy(ServerClassLoader.java,
              Compiled Code)
              at
              weblogic.cluster.AnnotatedServiceOffer.expandClassPath(AnnotatedServiceOffer
              .java, Compiled Code)
              at
              weblogic.cluster.AnnotatedServiceOffer.readObject(AnnotatedServiceOffer.java
              , Compiled Code)
              at
              weblogic.common.internal.WLObjectInputStreamBase.readPublicSerializable(WLOb
              jectInputStreamBase.java, Compiled Co
              de)
              at
              weblogic.common.internal.WLObjectInputStreamBase.readLeftover(WLObjectInputS
              treamBase.java, Compiled Code)
              at
              weblogic.common.internal.WLObjectInputStreamBase.readObjectBody(WLObjectInpu
              tStreamBase.java, Compiled Code)
              at
              weblogic.common.internal.WLObjectInputStreamBase.readObject(WLObjectInputStr
              eamBase.java, Compiled Code)
              at
              weblogic.common.internal.WLObjectInputStreamBase.readObjectWL(WLObjectInputS
              treamBase.java, Compiled Code)
              at
              weblogic.common.internal.WLObjectInputStreamBase.readArrayList(WLObjectInput
              StreamBase.java, Compiled Code)
              at weblogic.cluster.StateDump.readObject(StateDump.java, Compiled
              Code)
              at
              weblogic.common.internal.WLObjectInputStreamBase.readPublicSerializable(WLOb
              jectInputStreamBase.java, Compiled Co
              de)
              at
              weblogic.common.internal.WLObjectInputStreamBase.readLeftover(WLObjectInputS
              treamBase.java, Compiled Code)
              at
              weblogic.common.internal.WLObjectInputStreamBase.readObjectBody(WLObjectInpu
              tStreamBase.java, Compiled Code)
              at
              weblogic.common.internal.WLObjectInputStreamBase.readObject(WLObjectInputStr
              eamBase.java, Compiled Code)
              at
              weblogic.common.internal.WLObjectInputStreamBase.readObjectWL(WLObjectInputS
              treamBase.java, Compiled Code)
              at weblogic.cluster.TMSocket.execute(TMSocket.java, Compiled Code)
              at weblogic.kernel.ExecuteThread.run(ExecuteThread.java, Compiled
              Code)
              The message freshed about every 20 seconds.
              Another question, I used a iplanet web server as a proxy server with a
              cluster of two weblogic servers pluged in, although I set
              weblogic.properties to round-robin, however, when I run a fibonacci servlet,
              it does not do the round-robin. It always go to one machine for a lot of
              times. Any idea?
              Thank you for your help.
              Tom
              

    May i presume that your cluster is configured on a shared file system?.
              I have seen this problem only if you cluster is configured on different machines
              and if the directory structure is not identical.
              let us know..
              Kumar
              Cameron Purdy wrote:
              > First, update to SP4 (or SP5 if it is out now). Second, follow the cluster
              > instructions on setting up deployments for a cluster. The only
              > implementation that I have used is the single shared location that all the
              > servers load from.
              >
              > --
              >
              > Cameron Purdy
              > http://www.tangosol.com
              >
              > "Tom Gan" <[email protected]> wrote in message
              > news:[email protected]...
              > > Hi,
              > > I need some help.
              > >
              > > Product=weblogic5.1.0
              > > Revision=(Release Level)=
              > > Problem Description=
              > > I am doing cluster of weblogic server, I have no problem to set up the
              > > cluster and to run servlet and EJB examples.
              > > However, on my command line for startcluster I got a lot of message as
              > > followed:
              > > Fri Aug 18 11:31:44 EDT 2000:<E> <MulticastSocket> Multicast socket
              > receive
              > > error: java.lang.RuntimeException: I/O error opening JAR file from
              > > file:/D:/weblogic/mycluster/server86/tmp_deployments/ejbjar-17327.jar
              > > java.util.zip.ZipException: error in opening zip file
              > > at java.util.zip.ZipFile.open(Native Method)
              > > at java.util.zip.ZipFile.<init>(ZipFile.java, Compiled Code)
              > > at java.util.zip.ZipFile.<init>(ZipFile.java, Compiled Code)
              > > at weblogic.boot.ServerClassLoader.deploy(ServerClassLoader.java,
              > > Compiled Code)
              > > at
              > >
              > weblogic.cluster.AnnotatedServiceOffer.expandClassPath(AnnotatedServiceOffer
              > > .java, Compiled Code)
              > > at
              > >
              > weblogic.cluster.AnnotatedServiceOffer.readObject(AnnotatedServiceOffer.java
              > > , Compiled Code)
              > > at
              > >
              > weblogic.common.internal.WLObjectInputStreamBase.readPublicSerializable(WLOb
              > > jectInputStreamBase.java, Compiled Co
              > > de)
              > > at
              > >
              > weblogic.common.internal.WLObjectInputStreamBase.readLeftover(WLObjectInputS
              > > treamBase.java, Compiled Code)
              > > at
              > >
              > weblogic.common.internal.WLObjectInputStreamBase.readObjectBody(WLObjectInpu
              > > tStreamBase.java, Compiled Code)
              > > at
              > >
              > weblogic.common.internal.WLObjectInputStreamBase.readObject(WLObjectInputStr
              > > eamBase.java, Compiled Code)
              > > at
              > >
              > weblogic.common.internal.WLObjectInputStreamBase.readObjectWL(WLObjectInputS
              > > treamBase.java, Compiled Code)
              > > at
              > >
              > weblogic.common.internal.WLObjectInputStreamBase.readArrayList(WLObjectInput
              > > StreamBase.java, Compiled Code)
              > > at weblogic.cluster.StateDump.readObject(StateDump.java, Compiled
              > > Code)
              > > at
              > >
              > weblogic.common.internal.WLObjectInputStreamBase.readPublicSerializable(WLOb
              > > jectInputStreamBase.java, Compiled Co
              > > de)
              > > at
              > >
              > weblogic.common.internal.WLObjectInputStreamBase.readLeftover(WLObjectInputS
              > > treamBase.java, Compiled Code)
              > > at
              > >
              > weblogic.common.internal.WLObjectInputStreamBase.readObjectBody(WLObjectInpu
              > > tStreamBase.java, Compiled Code)
              > > at
              > >
              > weblogic.common.internal.WLObjectInputStreamBase.readObject(WLObjectInputStr
              > > eamBase.java, Compiled Code)
              > > at
              > >
              > weblogic.common.internal.WLObjectInputStreamBase.readObjectWL(WLObjectInputS
              > > treamBase.java, Compiled Code)
              > > at weblogic.cluster.TMSocket.execute(TMSocket.java, Compiled Code)
              > > at weblogic.kernel.ExecuteThread.run(ExecuteThread.java, Compiled
              > > Code)
              > >
              > > The message freshed about every 20 seconds.
              > >
              > > Another question, I used a iplanet web server as a proxy server with a
              > > cluster of two weblogic servers pluged in, although I set
              > > weblogic.properties to round-robin, however, when I run a fibonacci
              > servlet,
              > > it does not do the round-robin. It always go to one machine for a lot of
              > > times. Any idea?
              > > Thank you for your help.
              > > Tom
              > >
              > >
              > >
              

  • Multicast socket receive error: java.lang.RuntimeException: I/O error opening JAR file from file:/D:/weblogic/mycluster/server86/tmp_deployments/ejbjar-17327.jar

    Hi,
    I need some help.
    Product=weblogic5.1.0
    Revision=(Release Level)=
    Problem Description=
    I am doing cluster of weblogic server, I have no problem to set up the
    cluster and to run servlet and EJB examples.
    However, on my command line for startcluster I got a lot of message as
    followed:
    Fri Aug 18 11:31:44 EDT 2000:<E> <MulticastSocket> Multicast socket receive
    error: java.lang.RuntimeException: I/O error ope
    ning JAR file from
    file:/D:/weblogic/mycluster/server86/tmp_deployments/ejbjar-17327.jar
    java.util.zip.ZipException: error in opening zip file
    at java.util.zip.ZipFile.open(Native Method)
    at java.util.zip.ZipFile.<init>(ZipFile.java, Compiled Code)
    at java.util.zip.ZipFile.<init>(ZipFile.java, Compiled Code)
    at weblogic.boot.ServerClassLoader.deploy(ServerClassLoader.java,
    Compiled Code)
    at
    weblogic.cluster.AnnotatedServiceOffer.expandClassPath(AnnotatedServiceOffer
    .java, Compiled Code)
    at
    weblogic.cluster.AnnotatedServiceOffer.readObject(AnnotatedServiceOffer.java
    , Compiled Code)
    at
    weblogic.common.internal.WLObjectInputStreamBase.readPublicSerializable(WLOb
    jectInputStreamBase.java, Compiled Co
    de)
    at
    weblogic.common.internal.WLObjectInputStreamBase.readLeftover(WLObjectInputS
    treamBase.java, Compiled Code)
    at
    weblogic.common.internal.WLObjectInputStreamBase.readObjectBody(WLObjectInpu
    tStreamBase.java, Compiled Code)
    at
    weblogic.common.internal.WLObjectInputStreamBase.readObject(WLObjectInputStr
    eamBase.java, Compiled Code)
    at
    weblogic.common.internal.WLObjectInputStreamBase.readObjectWL(WLObjectInputS
    treamBase.java, Compiled Code)
    at
    weblogic.common.internal.WLObjectInputStreamBase.readArrayList(WLObjectInput
    StreamBase.java, Compiled Code)
    at weblogic.cluster.StateDump.readObject(StateDump.java, Compiled
    Code)
    at
    weblogic.common.internal.WLObjectInputStreamBase.readPublicSerializable(WLOb
    jectInputStreamBase.java, Compiled Co
    de)
    at
    weblogic.common.internal.WLObjectInputStreamBase.readLeftover(WLObjectInputS
    treamBase.java, Compiled Code)
    at
    weblogic.common.internal.WLObjectInputStreamBase.readObjectBody(WLObjectInpu
    tStreamBase.java, Compiled Code)
    at
    weblogic.common.internal.WLObjectInputStreamBase.readObject(WLObjectInputStr
    eamBase.java, Compiled Code)
    at
    weblogic.common.internal.WLObjectInputStreamBase.readObjectWL(WLObjectInputS
    treamBase.java, Compiled Code)
    at weblogic.cluster.TMSocket.execute(TMSocket.java, Compiled Code)
    at weblogic.kernel.ExecuteThread.run(ExecuteThread.java, Compiled
    Code)
    The message freshed about every 20 seconds.
    Another question, I used a iplanet web server as a proxy server with a
    cluster of two weblogic servers pluged in, although I set
    weblogic.properties to round-robin, however, when I run a fibonacci servlet,
    it does not do the round-robin. It always go to one machine for a lot of
    times. Any idea?
    Thank you for your help.
    Tom

    Hi,
    I need some help.
    Product=weblogic5.1.0
    Revision=(Release Level)=
    Problem Description=
    I am doing cluster of weblogic server, I have no problem to set up the
    cluster and to run servlet and EJB examples.
    However, on my command line for startcluster I got a lot of message as
    followed:
    Fri Aug 18 11:31:44 EDT 2000:<E> <MulticastSocket> Multicast socket receive
    error: java.lang.RuntimeException: I/O error ope
    ning JAR file from
    file:/D:/weblogic/mycluster/server86/tmp_deployments/ejbjar-17327.jar
    java.util.zip.ZipException: error in opening zip file
    at java.util.zip.ZipFile.open(Native Method)
    at java.util.zip.ZipFile.<init>(ZipFile.java, Compiled Code)
    at java.util.zip.ZipFile.<init>(ZipFile.java, Compiled Code)
    at weblogic.boot.ServerClassLoader.deploy(ServerClassLoader.java,
    Compiled Code)
    at
    weblogic.cluster.AnnotatedServiceOffer.expandClassPath(AnnotatedServiceOffer
    .java, Compiled Code)
    at
    weblogic.cluster.AnnotatedServiceOffer.readObject(AnnotatedServiceOffer.java
    , Compiled Code)
    at
    weblogic.common.internal.WLObjectInputStreamBase.readPublicSerializable(WLOb
    jectInputStreamBase.java, Compiled Co
    de)
    at
    weblogic.common.internal.WLObjectInputStreamBase.readLeftover(WLObjectInputS
    treamBase.java, Compiled Code)
    at
    weblogic.common.internal.WLObjectInputStreamBase.readObjectBody(WLObjectInpu
    tStreamBase.java, Compiled Code)
    at
    weblogic.common.internal.WLObjectInputStreamBase.readObject(WLObjectInputStr
    eamBase.java, Compiled Code)
    at
    weblogic.common.internal.WLObjectInputStreamBase.readObjectWL(WLObjectInputS
    treamBase.java, Compiled Code)
    at
    weblogic.common.internal.WLObjectInputStreamBase.readArrayList(WLObjectInput
    StreamBase.java, Compiled Code)
    at weblogic.cluster.StateDump.readObject(StateDump.java, Compiled
    Code)
    at
    weblogic.common.internal.WLObjectInputStreamBase.readPublicSerializable(WLOb
    jectInputStreamBase.java, Compiled Co
    de)
    at
    weblogic.common.internal.WLObjectInputStreamBase.readLeftover(WLObjectInputS
    treamBase.java, Compiled Code)
    at
    weblogic.common.internal.WLObjectInputStreamBase.readObjectBody(WLObjectInpu
    tStreamBase.java, Compiled Code)
    at
    weblogic.common.internal.WLObjectInputStreamBase.readObject(WLObjectInputStr
    eamBase.java, Compiled Code)
    at
    weblogic.common.internal.WLObjectInputStreamBase.readObjectWL(WLObjectInputS
    treamBase.java, Compiled Code)
    at weblogic.cluster.TMSocket.execute(TMSocket.java, Compiled Code)
    at weblogic.kernel.ExecuteThread.run(ExecuteThread.java, Compiled
    Code)
    The message freshed about every 20 seconds.
    Another question, I used a iplanet web server as a proxy server with a
    cluster of two weblogic servers pluged in, although I set
    weblogic.properties to round-robin, however, when I run a fibonacci servlet,
    it does not do the round-robin. It always go to one machine for a lot of
    times. Any idea?
    Thank you for your help.
    Tom

  • Need help with ABAP coding using java

    Dear experts,
    I have used ABAP to code many reports/function modules.However as i know java quite well,i want to achieve the same using java.I have utilized JCO to retrieve information from RFC in this mission.
    However i realized that i had to code all things using ABAP and use java only as interface to connect to
    SAP fetch that module and display information on console.It was not that fun.
    I want that i should not Login to SAP but work only using java.
    I heard SAP Netweaver is a good choice.But i dont know much about it.Will i be able to develop reports only by java and how ?
    Plz suggest.

    hi,
    I hope that you already have the J2ME Toolkit and that your emulator works okay. In the toolkit you get several examples to show you how to program a MIDlet. One has to do with a HTTP client server connection. Also in the API documentation for the J2ME there is a Connector class that you used to set up this communication and in the description of this class it pretty thoroughly explains how to set up an HTTP protocol client.
    However, if you want to do some other kind of networking then you are pretty much out of luck, as the TCPIP socket protocol has not been fully implemented and is optional to the J2ME specifications, only the HTTP protocol is certain to be available. This means that mobile phone companies can add other networking functionality to their phone's java virtual machine if they feel like it. This is a bummer I know.
    I hope this helps.
    Cheers,
    Mark

  • Process Identification using java- GUID

    How can I access a process identifier using java code?
    in fact i am developing a Group communication application, in which multiple processes communicate each other, and this requires unique identification of each process. for example to determine the sender of a message, i need identifier of the process which has sent the message.
    So please sugest me how can I use Process Identifier or Is there any alterative way, for example I have an idea to use some Globally unique identifier (GUID) for each Process involved, But I dont know actually how to implement that Gloabally Unique Identifier (GUID). Please help me to solve this issue.

    NadeemAbbas wrote:
    How can I access a process identifier using java code?You can't.
    >
    in fact i am developing a Group communication application, in which multiple processes communicate each other, and this requires unique identification of each process. for example to determine the sender of a message, i need identifier of the process which has sent the message.How do they communicate? Sounds like the socket is the identifier.
    Kaj

Maybe you are looking for

  • Problem with static and nonstatic objects in same code?

    Hi everyone, I am working on a project and I kept running into an odd problem where my code would compile but when I went to run the code I would get an exception. I finally narrowed my problem down to a small fragment. Here is an example. class Mut{

  • Video and audio not in sync (ALSA underrun occurred)

    Hi, after a recent system upgrade (upgrade log here http://pastebin.com/1gRwexFr), video and sound are not in sync anymore. The problem occurs in mplayer instantly, and in XBMC after a while (the audio is slowly getting out of sync). The error messag

  • PLSQL Info needed

    Hi, Currently I am using JDBC with Java servlets and JSP pages to talk to a Oracle DB to retrieve information, which is working fine. But I was recently assigned a task of getting the same or similar info from the same DB using a pl/sql package. Coul

  • Runtime dump error getting while goods posting

    Hi,gurus   When in MB1C i am trying to post goods.While saving i got message 49 number ranges should be defined.I done it clear in FBN1.So when i am saving posting goods i am getting runtime dump error.So how can i solve this problem Regards, Suresh

  • Desktop AIR Application installs fine on Mac... crashes on PC

    Hey guys, I ran into an issue that has be pulling my hair out. I have a very simple AIR application that was built with Flash CS6 on a Mac. The published app installs and runs perfectly on my Mac. Installation goes just fine on a PC, but the app will