Java performance prblm ..PLz help me

Hi
im running a java mutithreaded application, its small server it can handle aroung 200 clients.but after reaching 60-70cliemts .this clients r applets .server going to ideal or it will crash after one to two hour.i am giving aroung 730mb for that application.in the same machine Tomcat is running. If anybody knows more abt this prblm .Help me

void AcceptClient( Socket oClientSocket )
throws Exception
     try
     boolean bConnectionRequest = CheckForRequestRouterConnection(oClientSocket);
     if(bConnectionRequest)
          try
               oClientSocket.close();
               connectToRequestRouter();
               oMainScreen.append("Connected \n");
               oStream.sendRequest(oClientThreads.size());
          catch(Exception exp)
     else
CServerRequest oServerRq;
ObjectInputStream oInStream = new ObjectInputStream( oClientSocket.getInputStream() );
ObjectOutputStream oOutStream = new ObjectOutputStream( oClientSocket.getOutputStream() );
CUserStreamInfo oUserStream = new CUserStreamInfo();
oUserStream.oInStream = oInStream;
oUserStream.oOutStream = oOutStream;
oUserStream.oClntSocket = oClientSocket;
try
oServerRq = ( CServerRequest ) oInStream.readObject();
catch(Exception e)
ReleaseResources( oUserStream );
return;
oUserStream.oAccountId = oServerRq.oAccountId;
ClientNotifyThread oClientNotifyThread = new ClientNotifyThread(oServerRq.oAccountId, oUserStream.oOutStream, oServerRq.oAccountId );
oClientThreadList.put(oServerRq.oAccountId, oClientNotifyThread);
String[] sSocketProp = new String[4];
sSocketProp[0] = (oClientSocket.getInetAddress()+"").substring(1);
sSocketProp[1] = oClientSocket.getPort()+"" ;
sSocketProp[2] = oClientSocket.getInetAddress().getHostName();
sSocketProp[3] = ""+oClientSocket.isConnected();
oDisplayTable.put(oServerRq.oAccountId, sSocketProp);
if( SanityCheck( oServerRq,
oUserStream ) )
switch( oServerRq.iReqType )
case NESTconstants.QUOTES:
     oMainScreen.append(oServerRq.oAccountId + " : connected" + "\n");
oUserStreamHash.put( oServerRq.oAccountId,
oUserStream );
oClientThreads.put( oServerRq.oAccountId,
new ClientThread( this,
          oUserStream,
oServerRq.iDDInteractive,
oServerRq.sPortfolio));
UpdateTable();
boolean bSubscribed = false;
OMMisc.OMlog( oUserStream.oAccountId + " : Got Connected from "+oClientSocket.getInetAddress()+" @ "+new Date());
oUserStream.oDDInteractive = sDDInteractive;
oOmneLink.GetPortfolioNames(oServerRq.oAccountId);
oOmneLink.SubscribeForLogMsgs( oServerRq.oAccountId ,
                                        oUserStream.oDDInteractive );
if( bGeneralDataFlag )
bGeneralDataFlag = false;
oOmneLink.SubscribeForIndex(); // will work for both index and exchng time
} // if( bSensexFlag )
oOmneLink.GetBSELastIndex();
oOmneLink.GetNSELastIndex();
oMainScreen.append(oServerRq.oAccountId + "Connected @ "+new Date()+ "\n");
oStream.sendRequest(oClientThreads.size());
} // switch( iReqType )
} // if( SanityCheck() )
} // try
catch( Exception e )
e.printStackTrace();
} // catch()
} // method AcceptClient()
this is the code to accept new client. this will calld in side
public void run()
while( true )
try
AcceptClient( oServerSocket.accept() );
catch( Exception e )
     System.out.println(e);
//OMMisc.OMlog( "Run ( AcceptClient ) " + e.toString() );
} // catch()
} // while( true ) loop
} // method run()
now im running this application as Java Hotspot server VM.from today morning to till now no crashing.previosly it was running as normal application.that can give any changes(avoind crashes).
with regards
Jobin John

Similar Messages

  • MultiThreads and java.io.InterruptedIOException, Plz. help

    Dear javas,
    I have a multithreaded application, where I'm using wait and notify to make my thread communications, I'm using the java.io.File to get a list of files in the local folder, then read all these files and use the content of the files as my input, my problem is some time a java.io.InterruptedIOException is throwen, and I don't know why?
    it is thrown when I'm trying to read the content of the file, I browsed the Net for more than three days, and no bugs are reported or one have reported any thing.
    did I miss something??
    Bye the way, the problem happen on unix just, and not with windows
    also it happen with my code and with log4j package
    did any one have an idea or can help me?
    I ahve to deliver the project in the next comming day, and I'm stuck with this thing.
    I did find a work around with my code, but I can't do any thing with log4j
    I appreciate your help.

    did you read the exception description? obviously the thread reading the data was terminated too early. there could be an architectural problem with your design, e.g. the reader thread is a daemon thread and the main thread terminates without waiting for all tasks to be terminated.
    robert

  • Java Newbie Problem : plz help

    I'm having problem with the java command :
    [root@myServer datos]# export CLASSPATH=/usr/local/jdk/lib:/opt/tomcat/webapps/axis/WEB-INF/classes/org/enyuq/software/datos
    [root@myServer datos]# /usr/local/jdk/bin/java InformacionServidorLicencias
    Exception in thread "main" java.lang.NoClassDefFoundError: InformacionServidorLicencias (wrong name: org/enyuq/software/datos/InformacionServidorLicencias)
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
    at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
    at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
    [root@myServer datos]# /usr/local/jdk/bin/java org.enyuq.software.datos.InformacionServidorLicencias
    Exception in thread "main" java.lang.NoClassDefFoundError: org/enyuq/software/datos/InformacionServidorLicencias
    [root@myServer datos]#
    Can anybody help me with this error?
    Thanks

    some of the reasons why most people get this error
    The java file has not been compiled
    The java class does not have a main method(Applet or servlet) and is being run with the wrong tool.
    typing error for the name of the class

  • Need suggestions to start java card prog. plz help!!

    hi ppl....
    I am new to java card programming, but not to java programming. As a starter, i need to know ..... how to write a basic java card app?? Further, i also want to get the knowledge of testing/running this app on any simulator (if available). Can someone tell me that if i need to run my card application on real "smart card" (NOT on simulator), then what i need to have ... i mean any card processor or interface with PC. Any help will be much appreciated.
    Raheel.

    Download the sun kit and read the manuals

  • How can  I access my java class file in a .jar file ...PLz Help anyone!!

    Hi Folks,
    I am new in Java programming, have a .jar file that contains .java files that I want no access and use from another .java file. These files in the .jar file basically form a library thus have no main-method. However I can not declare an instance of the library (in the .jar file) and use it within my program.
    Plz help ...I have tried all I know in vain.
    Thanks.

    temba wrote:
    Hi Folks,
    I am new in Java programming, have a .jar file that contains .java files that I want no access and use from another .java file. These files in the .jar file basically form a library thus have no main-method. However I can not declare an instance of the library (in the .jar file) and use it within my program. You are making little sense. You can't instantiate .java files.
    Plz help ...I have tried all I know in vain.
    Thanks.Could you post WHAT you have tried and also post what error messages you received?

  • Plz help using ms access as database,i want to create a login page in java

    hye frnz... plz help me m new to java
    m using ms access as database and try to create a login page where user type username and pw
    i had enter valid user entries in database i checked connectivity is working i want as user login the main window must open after checking username and pw field to database but
    now there is an error class not found exception sun:jdbc...... error
    plz help me i had stuck frm 4 days */
    import java.sql.DriverManager;
    import java.sql.Connection;
    import java.sql.Statement;
    import java.sql.ResultSet;
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    class Login extends JFrame
    //Component Declarations
    JLabel jlb1,jlb2;
         JTextField jtf1;
         JPasswordField jpf1;
         JButton jb1,jb2;
         //Constructor
         Login()
         //frame settings
              setTitle("Login Dialog");
              setLayout(new GridBagLayout());
              GridBagConstraints gbc = new GridBagConstraints();
              setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
              Dimension d= Toolkit.getDefaultToolkit().getScreenSize();
              setBounds(d.width/2-175,d.height/2-100,350,200);
              gbc.insets=new Insets(7,7,7,7);
         //adding components
              jlb1=new JLabel("User ID");
              gbc.gridx=0;
              gbc.gridy=0;
              add(jlb1,gbc);
              jlb2=new JLabel("Password");
              gbc.gridx=0;
              gbc.gridy=1;
              add(jlb2,gbc);
              jtf1=new JTextField(10);
              gbc.gridx=1;
              gbc.gridy=0;
              add(jtf1,gbc);
              jpf1=new JPasswordField(10);
              gbc.gridx=1;
              gbc.gridy=1;
              add(jpf1,gbc);
              jb1=new JButton("Login");
              gbc.gridx=0;
              gbc.gridy=2;
              add(jb1,gbc);
              jb1.addActionListener(new ActionListener()
                   public void actionPerformed(ActionEvent ae)
                   Connection conn=null;
                        Statement stmt=null;
                        boolean found=false;
                   try
                             Class.forName("sun.jdbc.driver.JdbcOdbcDriver");
                             String dataSourceName = "Inventory";
                             String dbURL = "jdbc:odbc:" + dataSourceName;
                             conn=DriverManager.getConnection(dbURL, "","");
                             stmt=conn.createStatement();
                             ResultSet rst=stmt.executeQuery("Select * from User");
                             System.out.println(jtf1.getText()+"/t"+jpf1.getPassword());
                             while(rst.next())
                                  System.out.println( rst.getString(1) +"/t"+ rst.getString(2));
              if(jtf1.getText().equals(rst.getString(1).trim()) && new String(jpf1.getPassword()).equals(rst.getString(2).trim()))
                                       found=true;
                                       rst.close();
                                       dispose();
                                       MainWindow mw= new MainWindow();     /*created min window object created to be opend after login but not working*/     
                                       break;
                             rst.close();
                             stmt.close();
                             conn.close();                    
                        catch(ClassNotFoundException e){System.out.print(e);}
                        catch(Exception e){System.out.print(e);}
                        if(found==false) /*this portion is executing and dialog box appears invalid name and pw with class not found exception sun:jdbc.......on console */
                             JOptionPane.showMessageDialog(null,"Invalid username or password",
                                  "Error Message",JOptionPane.ERROR_MESSAGE);
              jb2=new JButton("Clear");
              gbc.gridx=1;
              gbc.gridy=2;
              add(jb2,gbc);
              jb2.addActionListener(new ActionListener()
                   public void actionPerformed(ActionEvent ae)
                        jtf1.setText("");
                        jpf1.setText("");
                        jtf1.requestFocus();
              setSize(350,200);
              setVisible(true);
              jtf1.requestFocus();
         public static void main(String args[])
    Login l=new Login();
    Edited by: 795772 on Sep 19, 2010 4:44 AM

    795772 wrote:
    hye frnz... plz help me m new to java
    m using ms access as database and try to create a login page where user type username and pw
    i had enter valid user entries in database i checked connectivity is working i want as user login the main window must open after checking username and pw field to database but
    now there is an error class not found exception sun:jdbc...... error
    plz help me i had stuck frm 4 days */
    <snip>The subject of this forum is Oracle databases. How does your problem relate to that subject?
    Two bits of advice:
    1) Make sure you ask questions in a forum related to your problem.
    2) If you want to be taken seriously as a professional, drop the MS IM Speak and use the language of the forum. In this forum it is English, which is successfully used by many people for whom English is far from their native language.

  • PLz Help New To Java

    Hey im brand new to java and i just downloaded and installed jdk-1_5_0_01-windows-i586-p now im tryin to set up the PATH permanently but i have no clue how to i went to the install notes and typed in C:\Program Files\Java\jdk1.5.0_<windows>\bin in the command.com but everytime i do it says access is denied. i have no clue how to set up the path permanently beside what i tried plz help!!!

    You didn't which OS you are running, but it's fairly similar for all windows.
    Start->settings->control panel->system->advanced->environment variables
    Go to System variables, click on path, click edit button and add a semicolon and the path at the end. DO NOT REPLACE EVERYTHING THAT'S THERE NOW.
    I don't have 1.5 installed on this computer, but I'm willing to bet the real path doesn't have '<windows>' in it. Use Windows Explorer to find out where java.exe actually exists on the hard disk and use that path

  • How to use padding scheme FIPS81 in java plz help?

    Plz refer the below code using this code I m trying to decrypt XLS file using pass phrase.
    I m using the same pass phrase which was used @ the time of encryption.
    But the problem I m facing is that the file was encrypted in DOT NET_ using padding scheme FIPS81 and there impelmentation of FIPS81 is not available in JAVA so that it gives exception at the time of decryption which is given below
    Exception : javax.crypto.BadPaddingException: Given final block not properly padded
    I urgently need the solution of this problem so somebody plz help me to find the solution of this problem.....Ur reply would be appriciated.....!!
    The File is Encrypted using below mechanism
    ALGORITHM : AES
    MODE : ECB
    PADDING SCHEME : FIPS81
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.FileOutputStream;
    import java.io.IOException;
    import java.io.UnsupportedEncodingException;
    import java.security.MessageDigest;
    import java.security.NoSuchAlgorithmException;
    import javax.crypto.*;
    import javax.crypto.spec.*;
    public class DecryptTest {
         public static void main(String[] s){
              String passPhrase = "passphrase";
              String encFileName = "encsample.xls";
              String decFileName = "decsample.xls";
              FileInputStream encFileIn = null;
              FileOutputStream decFileOut = null;
              File f = null;
              byte[] message;
              try {
                   f = new File(encFileName);
                   encFileIn = new FileInputStream(f);
                   decFileOut = new FileOutputStream(decFileName);
                   message = new byte[encFileIn.available()]; //Read the encrypted file in from disk
                   encFileIn.read(message);
                   SecretKeySpec spec = new SecretKeySpec(passwordToKey (passPhrase), "AES");
                   //decrypt it
                   Cipher c = Cipher.getInstance("AES/ECB/NoPadding");
                   c.init(Cipher.DECRYPT_MODE, spec);
                   System.out.println("Block Size is >-->" + c.getBlockSize());
                   String decryptedString = new String(c.doFinal(message));
                   System.out.println("Decrypted message: " + decryptedString);
                   //To write into another files
                   decFileOut.write(decryptedString.getBytes());
              }catch (Exception e) {
                   System.out.println(e);
              }finally {
                   try {
                        encFileIn.close();
                        decFileOut.close();     
                   } catch (IOException ioe) {
         }Is there any mechanism is available for FIPS81 or Is there any third party Provider available for it plz reply........????????

    I suggest you look in google http://www.google.co.uk/search?q=SWF+java

  • Plz help to install java plug-ins

    hi everybody,
    i am new to the world of java, i want to install java plug-ins in mozilla 1.7 on redhat linux 9.
    how to do it, plz help, thanx in advance..

    If Java was installed prior to Mozilla, it should have automatically installed.
    If not, or Mozilla was installed first, use these instructions from Mozilla:
    http://plugindoc.mozdev.org/linux.html

  • Java.rmi.MarshalException:....Broken pipe (plz help)

    Hi,
    I tried to run one simple RMI application..
    I got the RMI Server running...
    But While running the client I got the following Exception...
    java.rmi.MarshalException: error marshalling arguments; nested exception is:
    java.net.SocketException: Broken pipe
    at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:129)
    at engine.ServerMain_Stub.addTask(Unknown Source)
    at client.ClientMain.initCompute(ClientMain.java:38)
    at client.ClientMain.main(ClientMain.java:17)
    Caused by: java.net.SocketException: Broken pipe
    at java.net.SocketOutputStream.socketWrite0(Native Method)
    at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:92)
    at java.net.SocketOutputStream.write(SocketOutputStream.java:136)
    at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:66)
    at java.io.BufferedOutputStream.write(BufferedOutputStream.java:105)
    at java.io.ObjectOutputStream$BlockDataOutputStream.drain(ObjectOutputStream.java:1639)
    at java.io.ObjectOutputStream$BlockDataOutputStream.setBlockDataMode(ObjectOutputStream.java:1548)
    at java.io.ObjectOutputStream.writeNonProxyDesc(ObjectOutputStream.java:1146)
    at java.io.ObjectOutputStream.writeClassDesc(ObjectOutputStream.java:1100)
    at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1241)
    at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1052) at java.io.ObjectOutputStream.writeFatalException(ObjectOutputStream.java:1355)
    at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:281)
    at sun.rmi.server.UnicastRef.marshalValue(UnicastRef.java:265)
    at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:124)
    ... 3 more
    I am not able to understand the problem...
    Plz help..
    Regerds
    Jijo Vincent

    Hi, I got same stack trace within RMIConnector.
    MBean Server (= RIM Server) has bean alive, but a MBean client may get following Exception.
    I'm guessing that a port on server side was closed, cause rmi object on server side was unbinded from the rmi registory by some trigger.
    But I don't know what was the trigger for this...
    Caused by: java.rmi.MarshalException: error marshalling arguments; nested exception is:
    java.net.SocketException: Broken pipe
    at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:138)
    at com.sun.jmx.remote.internal.PRef.invoke(Unknown Source)
    at javax.management.remote.rmi.RMIConnectionImpl_Stub.invoke(Unknown Source)
    at javax.management.remote.rmi.RMIConnector$RemoteMBeanServerConnection.invoke(RMIConnector.java:993)
    at javax.management.MBeanServerInvocationHandler.invoke(MBeanServerInvocationHandler.java:288)
    ... 7 more
    Caused by: java.net.SocketException: Broken pipe
    at java.net.SocketOutputStream.socketWrite0(Native Method)
    at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:92)
    at java.net.SocketOutputStream.write(SocketOutputStream.java:136)
    at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:65)
    at java.io.BufferedOutputStream.write(BufferedOutputStream.java:109)
    at java.io.ObjectOutputStream$BlockDataOutputStream.drain(ObjectOutputStream.java:1847)
    at java.io.ObjectOutputStream$BlockDataOutputStream.writeByte(ObjectOutputStream.java:1885)
    at java.io.ObjectOutputStream.writeFatalException(ObjectOutputStream.java:1546)
    at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:333)
    at sun.rmi.server.UnicastRef.marshalValue(UnicastRef.java:274)
    at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:133)
    ... 11 more
    java.runtime.name = Java(TM) SE Runtime Environment
    java.runtime.version = 1.6.0_24-b07
    java.specification.name = Java Platform API Specification
    java.specification.vendor = Sun Microsystems Inc.
    java.specification.version = 1.6
    os.arch = amd64
    os.name = Linux
    os.version = 2.6.18-194.el5

  • PLZ HELP US IN IMPROVING PERFORMANCE

    Hi ,
    We recently installed solaris 10 (5.10) on sun sparc 64 bit machine and created oracle DB with 10.2.0.1 release .
    After solaris 10 installation, our application performance has come down drastically.
    The same application is running fine on solaris 9 ( 5.9 )
    Old configuration
    sun sparc 64 bit
    solaris 9 (no patches applied )     
    oarcle 10.2.0.1 (no patches applied )     
    jboss      3.2.7               
    jdk 1.4     
    New configuration
    sun sparc 64 bit
    solaris 10 (no patches applied )
    oarcle 10.2.0.1 (latest patches applied )
    jboss 4.2.0
    jdk 1.5_12
    we would like to know about any known Solaris , Oracle DB patches to address this performance issue.
    and also we would like to know about any incomapatability between the jboss and jdk we have used.
    Any solution to bring back performance, would be of great help to us.
    thanks a lot in advance.

    user645751 wrote:
    Hi ,
    We recently installed solaris 10 (5.10) on sun sparc 64 bit machine and created oracle DB with 10.2.0.1 release .
    After solaris 10 installation, our application performance has come down drastically.
    The same application is running fine on solaris 9 ( 5.9 )
    Old configuration
    sun sparc 64 bit
    solaris 9 (no patches applied )     
    oarcle 10.2.0.1 (no patches applied )     
    jboss      3.2.7               
    jdk 1.4     
    New configuration
    sun sparc 64 bit
    solaris 10 (no patches applied )
    oarcle 10.2.0.1 (latest patches applied )
    jboss 4.2.0
    jdk 1.5_12
    we would like to know about any known Solaris , Oracle DB patches to address this performance issue.
    and also we would like to know about any incomapatability between the jboss and jdk we have used.
    Any solution to bring back performance, would be of great help to us.You seem to have this issue now for quite a while? See here:
    PLZ HELP ME:::Degradation in performance of ORA-10G in solaris sparc
    Check your AWR reports on the new database if you can spot any notable issues there, if you have the license or install/check STATSPACK reports if you can't use AWR.
    You need to find out where the root cause of your problem is, and it might not be the database.
    In your old thread you had posted the same configuration for both systems, except for the O/S version. Now you seem to have upgraded a lot of the components like JBOSS version or the JDK version.
    oarcle 10.2.0.1 (latest patches applied )Does this mean 10.2.0.4, or what does "latest patches applied" but 10.2.0.1 as version mean?
    Open an SR with Oracle and ask them if they are aware of any generic Solaris 10 issues.
    In your last post you talked about "new stored procedures" so it wasn't clear if you really only changed the O/S or applied any changes to the application/database as well.
    Regards,
    Randolf
    Oracle related stuff blog:
    http://oracle-randolf.blogspot.com/
    SQLTools++ for Oracle (Open source Oracle GUI for Windows):
    http://www.sqltools-plusplus.org:7676/
    http://sourceforge.net/projects/sqlt-pp/

  • Java Mail Project HELP Required....URGENT PLZ HELP!!!

    hello there!!
    i took up a pjct for my engineering on java mail..got the code..and i thought that ill analyse it...the code is submitting the mail to the smtp server but after dat its failing to deliver to the client..as i can see this error in the logs on SMTP server...can anyone help me out in analysing this code!!!
    plz help, exams are near...(am new to java)
    //java FINAL!
    import javax.swing.*;
    import java.net.URL;
    import javax.mail.*;
    import javax.mail.internet.*;
    import java.util.*;
    import java.awt.*;
    import java.awt.event.*;
    public class EmailProg extends JPanel implements ActionListener {
    protected JTextArea textArea;
    protected String newline = "\n";
    static final private String composemail = "compose";
    static final private String sendmail = "send";
    static final private String about = "about";
    static final private String submit = "submit";
    static final private String exit = "exit";
    JLabel lSubmit = new JLabel("Submit");
    JButton subbutton = new JButton();
    JTextArea emailfrom = new JTextArea(1,1);
    JTextArea emailto = new JTextArea(1, 1);
    JTextArea emailsubject = new JTextArea(1, 1);
    JTextArea emailmessage = new JTextArea(25, 1);
    //------BAG LAYOUT
    JLabel lFrom = new JLabel("From:");
    JTextField cFrom = new JTextField(32);
    JLabel lTo = new JLabel("To:");
    JTextField cTo = new JTextField(32);
    JFrame frame2 = new JFrame("Compose New");
    JLabel lSubject = new JLabel("Subject");
    JTextField cSubject = new JTextField(32);
    JLabel lMessage = new JLabel("Body");
    JTextArea cMessage = new JTextArea(5,32);
    //====================================
    public EmailProg() {
    super(new BorderLayout());
    //Create the toolbar.
    JToolBar toolBar = new JToolBar();
    addButtons(toolBar);
    //Create the text area used for output. Request
    //enough space for 5 rows and 30 columns.
    textArea = new JTextArea(5, 30);
    textArea.setEditable(false);
    textArea.setText("Welcome to Jeff's email program! With this program you can compose and send emails. I hope I get a good grade on thise, and marine world finds a good use for it :-D:-D (implements really just testing the scroller!!!)");
    JScrollPane scrollPane = new JScrollPane(textArea);
    //Lay out the main panel.
    setPreferredSize(new Dimension(450, 110));
    add(toolBar, BorderLayout.NORTH);
    add(scrollPane, BorderLayout.CENTER);
    //==================================
    protected void addButtons(JToolBar toolBar) {
    JButton button = null;
    //first button
    button = makeNavigationButton("/toolbarButtonGraphics/general/ComposeMail24.gif", composemail ,"Compose new Email", "compose new");
    toolBar.add(button);
    //second button
    button = makeNavigationButton("toolbarButtonGraphics/general/SendMail24.gif", sendmail,"Send The Mail","send");
    toolBar.add(button);
    //third button
    button = makeNavigationButton("toolbarButtonGraphics/general/About24.gif", about,"About","About");
    toolBar.add(button);
    //exit button
    button = makeNavigationButton("toolbarButtonGraphics/general/Stop24.gif", exit, "Exit", "Exit");
    toolBar.add(button);
    //===================================
    protected JButton makeNavigationButton(String imageName, String actionCommand, String toolTipText, String altText) {
    //Look for the image.
    String imgLocation = imageName;
    URL imageURL = EmailProg.class.getResource(imgLocation);
    //Create and initialize the button.
    JButton button = new JButton();
    button.setActionCommand(actionCommand);
    button.setToolTipText(toolTipText);
    button.addActionListener(this);
    if (imageURL != null) {                      //image found
    button.setIcon(new ImageIcon(imageURL));
    } else {                                     //no image found
    button.setText(altText);
    System.err.println("Resource not found: "+ imgLocation);
    return button;
    //=============================
    public void actionPerformed(ActionEvent e) {
    String cmd = e.getActionCommand();
    String description = null;
    // Handle each button.
    if (exit.equals(cmd)){
    textArea.setText("");
    description = "EXITING";
    System.exit(0);
    if (composemail.equals(cmd)) { //first button clicked
    textArea.setText("");
    description = "Write new mail.";
    composeWindow();
    } else if (sendmail.equals(cmd)) { // second button clicked
    textArea.setText("");
    description = "This button does'nt do anything yet :x";
    } else if (about.equals(cmd)) { // third button clicked
    textArea.setText("");
    description = "About this program. (See pop-up)";
    coolWindow();
    else if (submit.equals(cmd))
    if (cFrom.getText().equals("")||cTo.getText().equals("")||cSubject.getText().equals("")||cMessage.getText().equals(""))
    textArea.setText("One or more of the fields was not filled in.");
    else{
    try {
    String smtpServer="serverhere";
    String to=cTo.getText();
    String from=cFrom.getText();
    String subject=cSubject.getText();
    String body=cMessage.getText();
    send(smtpServer, to, from, subject, body);
    textArea.setText("");
    description = "Mail Sent.";
    JOptionPane.showMessageDialog(null, "Message Sent.");
    catch (Exception ex)
    System.out.println("Usage: java com.lotontech.mail.SimpleSender"
    +" smtpServer toAddress fromAddress subjectText bodyText");
    //CLOSE THE FRAME2 WINDOW IIIIIIIIFFFFFFF SENDING IS SUCCESSFUL!!
    }//end of else during send
    }//end of if of submit
    displayResult(description);
    //============================
    protected void displayResult(String actionDescription) {
    textArea.append(actionDescription + newline);
    //=============================
    public void coolWindow() {
    JFrame frame = new JFrame("About");
    JTextArea filecontents = new JTextArea();
    filecontents.setText("Use the tool bar to compose\n compose new emails, in which you can\n send to anyone on the\n srvhs email server. \n Fill in all the blanks before pressing send. If you dont\n you will receive an error! \n For more information about this program click on the\n information button.");
    frame.getContentPane().add(filecontents, BorderLayout.CENTER);
    frame.pack();
    frame.setResizable(false);
    frame.setSize(300,200);
    frame.setVisible(true);
    //===============================
    public void composeWindow() {
    frame2.getContentPane().setLayout(new GridBagLayout());
    frame2.setResizable(false);
    frame2.setSize(600,500);
    frame2.setVisible(true);
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.insets = new Insets(5, 10, 5, 10);
    cMessage.setLineWrap(true);
    subbutton = makeNavigationButton("toolbarButtonGraphics/general/SendMail24.gif", submit,"submit","submit");
    addRow(gbc, lFrom, cFrom);
    addRow(gbc, lTo, cTo);
    addRow(gbc, lSubject, cSubject);
    addRow(gbc, lMessage, cMessage);
    addRow(gbc, lSubmit, subbutton);
    //===============================
    private void addRow(GridBagConstraints gbc, Component left, Component right) {
    gbc.gridx = GridBagConstraints.RELATIVE;
    gbc.gridy = GridBagConstraints.RELATIVE;
    gbc.gridheight = 1;
    gbc.gridwidth = 1;
    gbc.anchor = GridBagConstraints.EAST;
    frame2.getContentPane().add(left, gbc);
    gbc.gridwidth = GridBagConstraints.REMAINDER;
    gbc.anchor = GridBagConstraints.WEST;
    frame2.getContentPane().add(right, gbc);
    frame2.pack();
    //=======================
    public static void send(String smtpServer, String to, String from, String subject, String body) {
    try {
    Properties props = System.getProperties();
    props.put("localhost", smtpServer);
    Session session = Session.getDefaultInstance(props, null);
    System.out.println(smtpServer);
    // -- Create a new message --
    Message msg = new MimeMessage(session);
    // -- Set the FROM and TO fields --
    msg.setFrom(new InternetAddress(from));
    msg.setRecipients(Message.RecipientType.TO, InternetAddress.parse(to, false));
    // -- We could include CC recipients too --
    // if (cc != null)
    // msg.setRecipients(Message.RecipientType.CC
    // ,InternetAddress.parse(cc, false));
    // -- Set the subject and body text --
    msg.setSubject(subject);
    msg.setText(body);
    // -- Set some other header information --
    msg.setHeader("X-Mailer", "LOTONtechEmail");
    msg.setSentDate(new Date());
    // -- Send the message --
    Transport.send(msg);
    System.out.println("Message sent OK.");
    catch (Exception ex)
    ex.printStackTrace();
    public static void main(String[] args) {
    JFrame frame = new JFrame("EmailProg");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    EmailProg newContentPane = new EmailProg();
    newContentPane.setOpaque(true);
    frame.setContentPane(newContentPane);
    //Display the window.
    frame.pack();
    frame.setVisible(true);
    }

    The code to retrieve the messages from SMTP
    finally all working fine...
    thanx guys!!!
    package EmailProg;
    import javax.mail.*;
    import javax.mail.internet.*;
    import java.util.*;
    import java.io.*;
      * A simple email receiver class.
    public class SimpleReceiver
        * Main method to receive messages from the mail server specified
        * as command line arguments.
      public static void main(String args[])
        try
          String popServer=args[0];
          String popUser=args[1];
          String popPassword=args[2];
          receive(popServer, popUser, popPassword);
        catch (Exception ex)
          System.out.println("Usage: java com.mail.SimpleReceiver" +" popServer popUser popPassword");
        System.exit(0);
         * "receive" method to fetch messages and process them.
       public static void receive(String popServer, String popUser, String popPassword)
         Store store=null;
         Folder folder=null;
         try
           // -- Get hold of the default session --
           Properties props = System.getProperties();
           Session session = Session.getDefaultInstance(props, null);
           // -- Get hold of a POP3 message store, and connect to it --
           store = session.getStore("pop3");
           store.connect(popServer, popUser, popPassword);
           // -- Try to get hold of the default folder --
           folder = store.getDefaultFolder();
           if (folder == null) throw new Exception("No default folder");
           // -- ...and its INBOX --
           folder = folder.getFolder("INBOX");
           if (folder == null) throw new Exception("No POP3 INBOX");
           // -- Open the folder for read only --
           folder.open(Folder.READ_ONLY);
           // -- Get the message wrappers and process them --
           Message[] msgs = folder.getMessages();
           for (int msgNum = 0; msgNum < msgs.length; msgNum++)
             System.out.println(msgs[msgNum]);
         catch (Exception ex)
           ex.printStackTrace();
         finally
           // -- Close down nicely --
           try
             if (folder!=null) folder.close(false);
             if (store!=null) store.close();
           catch (Exception ex2) {ex2.printStackTrace();
      }

  • Plz help with a java app

    Dear experts,
    I have a java application in form of a running thread that periodically does an activity ie running a BAPI in
    SAP.I like to schedule this application at evening time.
    Problem is that incase somebody remotely login to this Windows server using RDP and leave an open RDP session,
    two instance starts one on RDP and other on console.
    Now to overcome this problem i devised a solution myself that incase application detects session is remote
    then it should exit itself. This is mentioned in forum undergiven.
    http://forums.sun.com/thread.jspa?threadID=5410674&messageID=10835701#10835701
    My perception behind carrying out this development was that incase session starts in remote then
    app will automatically close and finally letting running only in console.
    Now what happens is that scheduled task doesnot start at all on console ,incase console as well as RDP are open.
    Instead it starts only on RDP failing instantly.So in nutshell,task doesnot start at all.My app log say that
    service tried to open in remote session and got closed.Plz help as i have no way out.
    My second question is that if i schedule task using RDP on remote server,will it run on Remote,console or both
    of them.
    Regards,
    Aditya.

    Adi1000 wrote:
    My app also generates a .lock file and make sure that only one instance is running.Still problem remains unresolvedAnd combining your other thread with the word "also" from this post just exacerbates your "problem". Also, the "lock" file was not to prevent two simulteneous runs (that leads to very distasteful race condition), but rather to prevent two runs within a set period of time when combined with the ServerSocket approach to prevent simulteneous runs.

  • Multicore+java? Plz help..Thank You !

    Hi Friends,
    I have my first project review before the end of this month.I have problem in choosing the topic for my project.I am mostly interested in java,but my guide wants me to do the project in multicore.
    i need guidance on this.Please tell me some AIEE,ACE paper or other Research papers,which have to do with both java and multicore---I mean doing something in multicore with java.I Really need help.I tried myself to find such papers in AIEE and ACM but couldn't able to find one.so please help me.
    Thank You!

    First I'd like to apologize for being pissy earlier. I find it discouraging when I see people embarking on projects that have very little to not merit. Also this discussion has been had before and I dunno... Mostly though I had just come from a bad meeting and was in a bad mood and that really didn't help.
    Now on to the constructive bits.
    The two newish processor advances that people like to talk about are hyperthreading and multicore. As discussed previously these two are not related (although in marketing materials they often are which leads to some confusion). I do think though that some understanding of both can clear up some of other doubts people have regarding how "good" Java will be with these technologies.
    Hyperthreading
    Personally I think this one is very cool. The best way I can think to describe it is that it is like a hotspot optimizing compiler for the processor.
    What happens with hyperthreading is that the processor has more stuff on the go. The basic idea is this. In a normal processor you might have (simplified greatly here) the following steps to execute an instruction)
    1 Bits come in -> 2 bits are put into proper places -> 3 execution (the magic step -> 4 bits are put into proper places to go -> 5 bits go out
    Again simplfied but to get the idea. Each step takes a cycle of processor time to do it. In a non hyperthreading model each execution therefore takes 5 cycles. In hyperthreading it loads things up so that different instructions are at different life cycles in the processor at the same time. So maybe you have instructions at steps 1,3 and 5 all at the same time.
    This means that in theory things can go much faster. It's also interesting to note though that hyperthreading falls apart with code that has been prematurely optimized for a processor that didn't support hyperthreading. For example if the code tries to force things into processor registers.
    Multicore
    As mentioned multicore is just putting two or more core processing units on one die. This means actual parallel execution can happen.
    This is pretty simple. So what do you need in Java to take advantage of this? Well for starters you need multithreaded code. If your program has only one thread then it won't matter one bit.
    Beyond that? It's a combination of the VM and OS yes. There are already computers that have multiple processors of course so there is already existing VM's and OS's that can take advantage of this. There are a number of configuration options for Sun VM's to fiddle with how code should work on such systems.
    Perhaps surprisingly, or perhaps not, programs with multiple threads are often better off on one processor than multiple. Depends on load of course but you have to think of steps like synchronization. There is more complexity synchronizing across multiple processors than there is multiple threads on one processor. (Note not more complexity in your code but more complexity in how it is implemented by the VM and/or OS)
    Summary
    Both of these processor advancements mean good things for Java IMO. Hyperthreading in particular lends itself well to development in a language where runtime optimizations are performed. Why? Because in Java it is prefferred to gain performance by good design rather than resorting to hackery to squeeze performance from the processor directly.
    As systems grow more complex it is less and less likely that a specfic program can best judge how to tune it's own environment. Better to let a VM and/or OS and/or hardware to handle the optimization at runtime because it has the full picture of what is going on.
    It's like the same reason you really shouldn't call gc in your Java program. The VM knows at runtime far better than you at pre-compile time when it is a good idea to run a garbage collection.
    For multicore the same basic rules apply. Write good and well designed Java code and use existing and well established frameworks and it will work well on a multicore system. Write single threaded GUI apps or threading programs that have a tendency to deadlock and the outcome of multicore will be no better performance and possibly bugs that display themseleves with greater frequency.
    Further Resources
    http://blogs.sun.com/jag/entry/mpi_meets_multicore
    http://en.wikipedia.org/wiki/Hyper-threading
    http://en.wikipedia.org/wiki/Dual-core

  • Binary addition,subtraction and modulus...plz help urgent

    plz help me on this query...
    i need to pass two 512 bit number as string,then convert them to binary and
    then perform binary addition,subtraction,modulus operations on those two numbers.finally convert result to integer.
    i designed a code which doesnt work correct.it is:
    * To change this template, choose Tools | Templates
    * and open the template in the editor.
    package bytearrayopeations;
    import java.math.BigInteger;   
    * @author sheetalb
    public class binaryadding {
        public static void main(String[] args) {
            BigInteger a = new BigInteger("123456");
            BigInteger b = new BigInteger("5121");
            String bb1 = a.toString(2);
            String bb2 = b.toString(2);
            String ss1 = null;
            String ss2 = null;
            String result = "";
            String carry="0";
            System.out.println("first value=" +bb1);
            System.out.println("second value=" +bb2);
            int k=bb1.length();
            int h=bb2.length();
            System.out.println("length 1="+ k);
            System.out.println("length 2=" +h);
            int p=h-k;
            //System.out.println("difference=" +p);
            int q=k-h;
            //System.out.println("difference 2=" +q);
            if(h==k)
           else if(h>k)
                for(int i=0;i<p;i++)
                    bb1="0"+bb1;
                System.out.println("new value of first=" +bb1);   
        else if(h<k)
            for(int i=0;i<q;i++)
                bb2="0"+bb2;
            System.out.println("new value of second=" +bb2);
            StringBuffer sb1=new StringBuffer(bb1);
         StringBuffer sb2=new StringBuffer(bb2);
            bb1=sb1.reverse().toString();
         bb2=sb2.reverse().toString();
            //System.out.println("rev. buffer1=" +bb1);
            //System.out.println("rev. buffer2=" +bb2);
            for(int i=0;i<bb1.length();i++)
                ss1=bb1.substring(i,i+1);
                ss2=bb2.substring(i,i+1);
              System.out.println("value1=" + ss1 + "    " + "value2=" + ss2);
              if (ss1.equals("0") && ss2.equals("0")) 
                 if (carry.equals("0")) 
                     result+="0";
                        else
                            result+="1";
               else if (ss1.equals("1") && ss2.equals("1"))
                if (carry.equals("0")) 
                    result+="0";
              carry="1";
              else
                   result+="1";
                   carry="1";
        else if (ss1.equals("0") && ss2.equals("1"))
                     if (carry.equals("0")) 
                         result+="1";
                   carry="0";
                        else
                          result+="0";
                                    carry="1";
               else if (ss1.equals("1") && ss2.equals("0"))
                     if (carry.equals("0")) 
                        result+="1";
                        carry="0";
                   else
                                result+="0";
                                carry="1";
           System.out.println("sum=" +result + "         " + "carry" + carry);
                        result+=carry;
                        StringBuffer sb3=new StringBuffer(result);
                        result=sb3.reverse().toString();
                    System.out.println("result is " +result); 
                  System.out.println("Binary = "+ result + ", Decimal = "+Integer.parseInt(result,2));
    }plz provide me or email me if possible java coding for all three operations as soon.
    [email protected]

    One thread is enough. Continue here:[http://forums.sun.com/thread.jspa?threadID=5373720&messageID=10643157#10643157]

Maybe you are looking for