Java Net Programming

Hello there,
I am recently writting an Client/Server program for my final year project. At the begining i just only think aboout single client access into server. And it works perfectly. Now the requirements changing and ask me to make it multi-client.
Iam using thread to control multi-client and it also work. But when the client1 send information then client2 then back to client1. And so on then socket is closed and data is corrupted because the server doesnot know which client is it talking to. I know that i am using thread not properly. Actually i don't really much understand thread so that why my program doesnot work properly.
I know this is too general question. But from your experience could you suggest me some resource from internet to look up more information about thread. And when using thread to control the connection for client and how do we control the input and output from client and server. Some suggestions please
My programs is based on GUIs and if so should i put thread on the button or menuitem something.
Thanks alot

I think i should use thread because i should enable multiple clients access to my server.
Actually what am i doing is :
I have a server running and client access in make a request to server then feedback the files or whatsoever data that server make and send back to client.
when i run another client. the data send to Server is corrupted because server doesnot know which one is for client 1 or client 2 as i said. If i use thread to control the connections only or control the action between the server and client. Iam not really good at thread so that my server disconnect the client.
What strategy would you use if you doing this. Just in generally
Thanks

Similar Messages

  • I am running Mac OS 10.6.7 I cannot run a java based program from the net when parental controls are set the error is The error is Load: class installer.CheckVersion 13. class not found  Help!

    I am running Mac OS 10.6.7 I cannot run a java based program from the net when parental controls are set the error is The error is Load: class installer.CheckVersion 13. class not found 

    Then, talk to the person running the lab.

  • MySQL and Java - getting program to work

    I am setting up mysql to run sql from a Java program on my pc at home and probably biting off more than I can chew. I get these messages when executing the java program ExecuteSQL.java:
    Exception in thread "main" java.lang.NoClassDefFoundError: Test2 <wrong name: MyProjects/test2/Test2>
    at java.lang.ClassLoader.defineClass0<Native Method>
    at java.lang.ClassLoader.defineClass<Unknown Source>
    at java.security.SecurityClassLoader.defineClass<Unknown Source>
    at java.net.URLClassLoader.defineClass<Unknown Source>
    at java.net.URLClassLoader.access$100<Unknown Source>
    at java.net.URLClassLoader$1.run<Unknown Source>
    at java.security.AccessController.ddPrivileged<Native Method>
    at java.lang.ClassLoader.findClass<Unknown Source>
    at java.lang.ClassLoader.loadClass<Unknown Source>
    at sun.misc.Launcher$AppClassLoader.loadClass<Unknown Source>
    at java.lang.ClassLoader.loadClass<Unknown Source>
    at java.lang.ClassLoader.loadClassInternal<Unknown Source>
    This is what I did.
    I created a folder on my C: drive named MySQL.
    I downloaded these two zip files form the MySQL website
         * mysql-connector-java-3.0.11-stable
         * mysql-4.0.18-win.zip
    Installed both of these in folder MySQL.
    I modified this line in the program ("ExecuteSQL" 1st pgm in chapter 17) I got from "Java Examples In a Nutshell" and compiled it into directory jwork.
    String driver = "com.mysql.jdbc.driver", url = "jdbc:mysql://", user = "", password = "";
    The readme file talks about putting a jar file in $JAVA_HOME/jre/lib/ext.
    the word "Java_Home" (I now know) is not literally the name but represents the
    name of the folder where the JDK to be used exists. So I put a copy of
    mysql-connector-java-3.0.11-stable-bin.jar in folder C:\JDK14/jre/lib/ext.
    Then I get a ClassNotFoundException error com.mysql.jdbc.driver.
    After finding
    http://forum.java.sun.com/thread.jsp?forum=31&thread=439796
    and
    http://forum.java.sun.com/thread.jsp?forum=31&thread=499888
    and others, I copied (a second copy) the jar file to the directory where I am create my java objects.
    Then I unzipped it to that directory, creating three folders that hold the unzipped objects.
    I tried executing the program again. I get the messages at the top of this post.
    The Manifest file is in one of the three folders unzipped to my java work directory.
    In the second of the two above threads, jsalonen says:
    the problem can be solved by mentioning mysql.jar in the Class-Path attribute
    in the manifest of the jar file:
    In this "manifest" file, there are only three lines and I added a fourth and it looks like this
    (there are two, one in directory MySQL\META-INF and one in directory jwork\META-INF:
    Manifest-Version: 1.0
    Ant-Version: Apache Ant 1.6.1
    Created-By: 1.4.0_01-b03 (Sun Microsystems Inc.)
    Main-Class:jwork\ExecuteSQL
    How do I "mention" mysql.jar in the class path attribute?
    In the index.list file (in the directory with the manifest file, do I need to add anything to refer that "com.mysql.jdbc.driver" is the driver?
    Do I need index.list in MySQL\META-INF ?
    Thank you for your help. The program ExecuteSQL follows.
    * Copyright (c) 2000 David Flanagan. All rights reserved.
    * This code is from the book Java Examples in a Nutshell, 2nd Edition.
    * It is provided AS-IS, WITHOUT ANY WARRANTY either expressed or implied.
    * You may study, use, and modify it for any non-commercial purpose.
    * You may distribute it non-commercially as long as you retain this notice.
    * For a commercial use license, or to purchase the book (recommended),
    * visit http://www.davidflanagan.com/javaexamples2.
    /** package com.davidflanagan.examples.sql; */
    import java.sql.*;
    import java.io.*;
    * A general-purpose SQL interpreter program.
    public class ExecuteSQL {
    public static void main(String[] args) {
    Connection conn = null; // Our JDBC connection to the database server
    try {
    String driver = "com.mysql.jdbc.driver", url = "jdbc:mysql://",
    user = "", password = "";
    // Parse all the command-line arguments
    for(int n = 0; n < args.length; n++) {
    if (args[n].equals("-d")) driver = args[++n];
    else if (args[n].equals("-u")) user = args[++n];
    else if (args[n].equals("-p")) password = args[++n];
    else if (url == null) url = args[n];
    else throw new IllegalArgumentException("Unknown argument.");
    // The only required argument is the database URL.
    if (url == null)
    throw new IllegalArgumentException("No database specified");
    // If the user specified the classname for the DB driver, load
    // that class dynamically. This gives the driver the opportunity
    // to register itself with the DriverManager.
    if (driver != null) Class.forName(driver);
    // Now open a connection the specified database, using the
    // user-specified username and password, if any. The driver
    // manager will try all of the DB drivers it knows about to try to
    // parse the URL and connect to the DB server.
    conn = DriverManager.getConnection(url, user, password);
    // Now create the statement object we'll use to talk to the DB
    Statement s = conn.createStatement();
    // Get a stream to read from the console
    BufferedReader in =
              new BufferedReader(new InputStreamReader(System.in));
    // Loop forever, reading the user's queries and executing them
    while(true) {
    System.out.print("sql> "); // prompt the user
    System.out.flush(); // make the prompt appear now.
    String sql = in.readLine(); // get a line of input from user
    // Quit when the user types "quit".
    if ((sql == null) || sql.equals("quit")) break;
    // Ignore blank lines
    if (sql.length() == 0) continue;
    // Now, execute the user's line of SQL and display results.
    try {
    // We don't know if this is a query or some kind of
    // update, so we use execute() instead of executeQuery()
    // or executeUpdate() If the return value is true, it was
    // a query, else an update.
    boolean status = s.execute(sql);
              // Some complex SQL queries can return more than one set
              // of results, so loop until there are no more results
    do {
    if (status) { // it was a query and returns a ResultSet
    ResultSet rs = s.getResultSet(); // Get results
    printResultsTable(rs, System.out); // Display them
    else {
    // If the SQL command that was executed was some
    // kind of update rather than a query, then it
    // doesn't return a ResultSet. Instead, we just
    // print the number of rows that were affected.
    int numUpdates = s.getUpdateCount();
    System.out.println("Ok. " + numUpdates +
                             " rows affected.");
    // Now go see if there are even more results, and
    // continue the results display loop if there are.
    status = s.getMoreResults();
    } while(status || s.getUpdateCount() != -1);
    // If a SQLException is thrown, display an error message.
    // Note that SQLExceptions can have a general message and a
    // DB-specific message returned by getSQLState()
    catch (SQLException e) {
    System.err.println("SQLException: " + e.getMessage()+ ":" +
                        e.getSQLState());
    // Each time through this loop, check to see if there were any
    // warnings. Note that there can be a whole chain of warnings.
    finally { // print out any warnings that occurred
              SQLWarning w;
    for(w=conn.getWarnings(); w != null; w=w.getNextWarning())
    System.err.println("WARNING: " + w.getMessage() +
                             ":" + w.getSQLState());
    // Handle exceptions that occur during argument parsing, database
    // connection setup, etc. For SQLExceptions, print the details.
    catch (Exception e) {
    System.err.println(e);
    if (e instanceof SQLException)
    System.err.println("SQL State: " +
                        ((SQLException)e).getSQLState());
    System.err.println("Usage: java ExecuteSQL [-d <driver>] " +
                   "[-u <user>] [-p <password>] <database URL>");
    // Be sure to always close the database connection when we exit,
    // whether we exit because the user types 'quit' or because of an
    // exception thrown while setting things up. Closing this connection
    // also implicitly closes any open statements and result sets
    // associated with it.
    finally {
    try { conn.close(); } catch (Exception e) {}
    * This method attempts to output the contents of a ResultSet in a
    * textual table. It relies on the ResultSetMetaData class, but a fair
    * bit of the code is simple string manipulation.
    static void printResultsTable(ResultSet rs, OutputStream output)
         throws SQLException
    // Set up the output stream
    PrintWriter out = new PrintWriter(output);
    // Get some "meta data" (column names, etc.) about the results
    ResultSetMetaData metadata = rs.getMetaData();
    // Variables to hold important data about the table to be displayed
    int numcols = metadata.getColumnCount(); // how many columns
    String[] labels = new String[numcols]; // the column labels
    int[] colwidths = new int[numcols]; // the width of each
    int[] colpos = new int[numcols]; // start position of each
    int linewidth; // total width of table
    // Figure out how wide the columns are, where each one begins,
    // how wide each row of the table will be, etc.
    linewidth = 1; // for the initial '|'.
    for(int i = 0; i < numcols; i++) {             // for each column
    colpos[i] = linewidth; // save its position
    labels[i] = metadata.getColumnLabel(i+1); // get its label
    // Get the column width. If the db doesn't report one, guess
    // 30 characters. Then check the length of the label, and use
    // it if it is larger than the column width
    int size = metadata.getColumnDisplaySize(i+1);
    if (size == -1) size = 30; // Some drivers return -1...
         if (size > 500) size = 30; // Don't allow unreasonable sizes
    int labelsize = labels.length();
    if (labelsize > size) size = labelsize;
    colwidths[i] = size + 1; // save the column the size
    linewidth += colwidths[i] + 2; // increment total size
    // Create a horizontal divider line we use in the table.
    // Also create a blank line that is the initial value of each
    // line of the table
    StringBuffer divider = new StringBuffer(linewidth);
    StringBuffer blankline = new StringBuffer(linewidth);
    for(int i = 0; i < linewidth; i++) {
    divider.insert(i, '-');
    blankline.insert(i, " ");
    // Put special marks in the divider line at the column positions
    for(int i=0; i<numcols; i++) divider.setCharAt(colpos[i]-1,'+');
    divider.setCharAt(linewidth-1, '+');
    // Begin the table output with a divider line
    out.println(divider);
    // The next line of the table contains the column labels.
    // Begin with a blank line, and put the column names and column
    // divider characters "|" into it. overwrite() is defined below.
    StringBuffer line = new StringBuffer(blankline.toString());
    line.setCharAt(0, '|');
    for(int i = 0; i < numcols; i++) {
    int pos = colpos[i] + 1 + (colwidths[i]-labels[i].length())/2;
    overwrite(line, pos, labels[i]);
    overwrite(line, colpos[i] + colwidths[i], " |");
    // Then output the line of column labels and another divider
    out.println(line);
    out.println(divider);
    // Now, output the table data. Loop through the ResultSet, using
    // the next() method to get the rows one at a time. Obtain the
    // value of each column with getObject(), and output it, much as
    // we did for the column labels above.
    while(rs.next()) {
    line = new StringBuffer(blankline.toString());
    line.setCharAt(0, '|');
    for(int i = 0; i < numcols; i++) {
    Object value = rs.getObject(i+1);
              if (value != null)
              overwrite(line, colpos[i] + 1, value.toString().trim());
    overwrite(line, colpos[i] + colwidths[i], " |");
    out.println(line);
    // Finally, end the table with one last divider line.
    out.println(divider);
    out.flush();
    /** This utility method is used when printing the table of results */
    static void overwrite(StringBuffer b, int pos, String s) {
    int slen = s.length(); // string length
    int blen = b.length(); // buffer length
    if (pos+slen > blen) slen = blen-pos; // does it fit?
    for(int i = 0; i < slen; i++) // copy string into buffer
    b.setCharAt(pos+i, s.charAt(i));

    Don't put those JARs in the lib/ext directory. Only language extensions (e.g., packages that start with "javax") belong in there.
    Learn how to set the CLASSPATH properly for starters:
    http://java.sun.com/j2se/1.4.2/docs/tooldocs/windows/classpath.html
    You might want to look at the JDBC tutorial, too:
    http://java.sun.com/docs/books/tutorial/jdbc/
    Do one thing at a time. Get the program to work, then worry about packaging it into an executable JAR.

  • Inputting an excel file to the java servlet program

    Hi,
    How can I input an excel file into the java servlet program? I am using POI HSSF programming to read the content of that excel file.I have created a form that will accept the path from the user and in the servlet program, I have called a post method to retrieve the path of the file. I am getting the path of the file as a string.Then I have to access the file to read the data. But it is not working. What should I do?.Please help me.
    I have created an html file to create a form that will ask the path of the file to be loaded into the servlet program.Please give me a solution,thanks in advance. The servlet program that receives the file is shown below. It just only take the name of the file and prints if that is ok.
    <html>
    <body bgcolor="green">
    <center>
    <form method="post"  action="http://localhost:8080/examples/servlet/Ron1">
    <table>
    <tr>
    <td><B>ENTER THE PATH OF THE FILE</td>
    <td><input type=file name="path"></td>
    </tr>
    </table>
    <input type=submit value= "submit" >
    </form>
    </body>
    </html>
    import java.io.*;
    import javax.servlet.*;
    import java.lang.*;
    import javax.servlet.http.*;
    import java.sql.*;
    import java.text.*;
    import java.util.*;
    import com.oreilly.servlet.MultipartRequest;
    import org.apache.poi.hssf.usermodel.*;
    public class Ron1 extends HttpServlet
       public void doPost(HttpServletRequest request, HttpServletResponse response)   throws IOException, ServletException
            response.setContentType("text/html");
            PrintWriter out = response.getWriter();
            String u = request.getParameter("FileToUpload");
            out.println("The Path is "+u);
            System.out.println("The path is "+u);
            MultipartRequest multi = new MultipartRequest(request,u,10 * 1024 * 1024);
            System.out.println("path is "+u);
            Enumeration files = multi.getFileNames();
            File fUploadedFile = null;
            String sFileName = "";
            out.println("path is "+u);
            while(files.hasMoreElements())
                            String name = (String)files.nextElement();
                            out.println("file is "+name);
                            sFileName = multi.getFilesystemName(name);
                            String type = multi.getContentType(name);
                            fUploadedFile = multi.getFile(name);
                    FileInputStream fis= new FileInputStream(fUploadedFile);
                   HSSFWorkbook wb=new HSSFWorkbook(fis);
                    System.out.println("The path is "+u);
                    out.println("File has identified successfully\n");
                    out.close();
       }

    Hi,
    Can you try to use classes from java.net package (URL, URLConnection) to pass the contents of excel file to servlet?
    HTH
    Vishal

  • "Java Concurrent Program" java.lang.ClassNotFoundException:

    I am creating one Concurrent Program Type "Java Concurrent Program",
    I followed steps as notes "250964.1"
    Deployed the java file to specific Directory in $JAVA_TOP
    Bounce the apache.
    I am getting this issue?
    java.lang.ClassNotFoundException: oracle.apps.fnd.cp.sample.Hello
         at java.net.URLClassLoader.findClass(URLClassLoader.java:376)
         at java.lang.ClassLoader.loadClass(ClassLoader.java(Compiled Code))
         at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:442)
         at java.lang.ClassLoader.loadClass(ClassLoader.java:502)
         at java.lang.Class.forName1(Native Method)
         at java.lang.Class.forName(Class.java:180)
         at oracle.apps.fnd.cp.request.Run.main(Run.java:157)
    I am not getting this issue OA Framework Classes (CO, AM ....)
    Looking for this solution ? This is urgent to me.
    Let us know what may be issue?
    Thanks, Avaneesh

    Avaneesh,
    What do you mean by "
    I am not getting this issue OA Framework Classes (CO, AM ....)"?
    Did you test your java code on command line?
    --Shiv                                                                                                                                                                                                                                                                                                                           

  • Java Concurrent Program issue

    Hello,
    I am fairly new the Java Concurrent Programs concept. I was just trying a simple Hello World example but I cannot seem to run it from the operating system. Here is my Hello World java program I created using Jdeveloper:
    package oracle.apps.fnd.cp.request;
    public class Hello implements JavaConcurrentProgram {
    public static final String RCS_ID = "$Header$";
    public void runProgram(CpContext ctx) {
    ctx.getLogFile().writeln("-- Hello World! --", 0);
    ctx.getOutFile().writeln("-- Hello World! --");
    ctx.getReqCompletion().setCompletion(ReqCompletion.NORMAL, "");
    It compiles fine in Jdev generating the class file. Here is what I did :
    1) Created directory under $JAVA_TOP as follows :
    mkdir $JAVA_TOP/oracle/apps/fnd/cp/sample
    2) moved the Hello.java file there under sample directory
    3) compiled java file using avac $JAVA_TOP/oracle/apps/fnd/cp/sample/Hello.java ( It compiles fine generating the class file )
    4) Now I wanted to test running it : I tried using jre command first as I saw in other posts but this is not working :
    jre -Ddbcfile=$FND_TOP/secure/k021kp-6180_r115dev1.dbc -Drequest.outfile=/export/home/sqadri/outfile oracle.apps.fnd.cp.request.Run oracle.apps.fnd.cp.sample.Hello
    Error :
    ksh: jre: not found
    Then I tried using the other way I saw on posts which is using the java command :
    java -cp $AF_CLASSPATH -Ddbcfile=$FND_TOP/secure/k021kp-6180_r115dev1.dbc -Drequest.outfile=/export/home/sqadri/outfile oracle.apps.fnd.cp.request.Run oracle.apps.fnd.cp.sample.Hello
    This gives me the following error :
    java.lang.NoClassDefFoundError: oracle/apps/fnd/cp/sample/Hello (wrong name: oracle/apps/fnd/cp/request/Hello)
    at java.lang.ClassLoader.defineClass0(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:539)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:123)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:251)
    at java.net.URLClassLoader.access$100(URLClassLoader.java:55)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:194)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:187)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:289)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:274)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
    at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:141)
    at oracle.apps.fnd.cp.request.Run.main(Run.java:157)
    Can anyone tell me what I am doing wrong ? I have tried everything even tried ftp the class file from my local but I get the same error. Any help would be appreciated.
    Thanks

    Ajay,
    Yes you are right. I did not register my java program yet in the concurrent programs.
    I thought I could test it out from the operating system command line before registering it. But looking at your document you sent me it seems I have to do all the steps i.e. define concurrent program etc before I can test it from the operating system. If that's the case then what's the use of trying to test it via operating system using
    java -cp $AF_CLASSPATH -Ddbcfile=$FND_TOP/secure/k021kp-6180_r115dev1.dbc -Drequest.outfile=/export/home/sqadri/outfile oracle.apps.fnd.cp.request.Run oracle.apps.fnd.cp.sample.Hello
    Thanks
    Syed

  • How to integrate a class with template.java - Java Concurrent Program. 11i

    Hello, I have a java class I got from a vendor. This java class needs to run through as concurrent program. As per metalink note *How To Create a Java Concurrent Program? [ID 827563.1]* it says that, we must require template.java to wrap around the custom class. I have done that in the following java code. However, being a new java guy, I really dont know how to connect these two classes and constructor.
    Any suggestions about how do I make these classes work in order to run from a concurrent program?
    package oracle.apps.fnd.cp.request;
    import oracle.apps.fnd.util.*;
    import oracle.apps.fnd.cp.request.*;
    import java.io.BufferedReader;
    import java.io.IOException;
    import javax.net.ssl.SSLSocketFactory;
    public class cyberBatch implements JavaConcurrentProgram {
        // Optionally provide class constructor without any arguments.
        // If you provide any arguments to the class constructor then while running the program will fail.
        public void runProgram(CpContext pCpContext) {
            ReqCompletion lRC = pCpContext.getReqCompletion();
            String CompletionText = "";
        // This class is to upload files but can be expanded to download files also.
        public class SSLFileTransfer {
            Properties props =
                new Properties(); // stores properties from property file
       * SSLFileTransfer(): constructor
            public SSLFileTransfer() {
       * init(): initialization (load property file)
          * @param propsFile          properties needed for file transfer
            public void init(String propsFile) {
                try {
                    props.load(new BufferedInputStream(new FileInputStream(new File(propsFile))));
                } catch (Exception e) {
                    e.printStackTrace();
                    System.exit(-1);
       * usage()
            public static void usage() {
                System.out.println("USAGE: java SSLFileTransfer <full path property file name>");
                System.exit(-1);
       * getFactory(): get factory for authentication
          * @throws IOException     if exception occurs
            private SSLSocketFactory getFactory() throws IOException {
                try {
                    SSLContext ctx;
                    KeyManagerFactory kmf;
                    KeyStore ks, ks1;
                    char[] passphrase =
                        props.getProperty("passPhrase").toCharArray();
                    ctx = SSLContext.getInstance("TLS");
                    kmf = KeyManagerFactory.getInstance("SunX509");
                    ks = KeyStore.getInstance("PKCS12", "BC");
                    ks1 = KeyStore.getInstance("JKS");
                    ks.load(new FileInputStream(props.getProperty("key")),
                            passphrase);
                    ks1.load(new FileInputStream(props.getProperty("keyStore")),
                             passphrase);
                    kmf.init(ks, passphrase);
                    TrustManagerFactory tmf =
                        TrustManagerFactory.getInstance("SunX509");
                    tmf.init(ks1);
                    ctx.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null);
                    return ctx.getSocketFactory();
                } catch (Exception e) {
                    e.printStackTrace();
                    throw new IOException(e.getMessage());
       * getHost(): Get host from property file
            private String getHost() {
                return props.getProperty("host", "localhost");
       * getPort(): Get port from property file
            private int getPort() {
                return Integer.parseInt(props.getProperty("port"));
       * sendRequest(): Send request (file) to the server
          * @param out          stream to send the data to the server
          * @throws Exception     if an error occurs.
            private void sendRequest(PrintWriter out) throws Exception {
                String path = props.getProperty("path");
                out.println("POST " + path + " HTTP/1.0");
                final String BOUNDARY = "7d03135102b8";
                out.println("Content-Type: multipart/form-data; boundary=" +
                            BOUNDARY);
                String uploadFile = props.getProperty("uploadFile");
                String authString =
                    props.getProperty("bcUserName") + ":" + props.getProperty("bcPassword");
                String encodedAuthString =
                    "Basic " + new sun.misc.BASE64Encoder().encode(authString.getBytes());
                out.println("Authorization: " + encodedAuthString);
                final String CRLF = "\r\n";
                StringBuffer sbuf = new StringBuffer();
                sbuf.append("--" + BOUNDARY + CRLF);
                sbuf.append("Content-Disposition: form-data; name=\"upfile\"; filename=\"" +
                            uploadFile + "\"" + CRLF);
                sbuf.append("Content-Type: text/plain" + CRLF + CRLF);
                FileReader fi = new FileReader(uploadFile);
                char[] buf = new char[1024000];
                int cnt = fi.read(buf);
                sbuf.append(buf, 0, cnt);
                sbuf.append(CRLF);
                sbuf.append("--" + BOUNDARY + "--" + CRLF);
                int sz = sbuf.length();
                out.println("Content-Length: " + sz);
                out.println();
                out.println(sbuf);
                out.flush();
                // Make sure there were no surprises
                if (out.checkError())
                    System.out.println("SSLFileTransfer: java.io.PrintWriter error");
       * readResponse(): reads response from the server
          * @param in          stream to get the data from the server
          * @throws Exception     if an error occurs.
            private void readResponse(BufferedReader in) throws Exception {
                boolean successful = false;
                String inputLine;
                while ((inputLine = in.readLine()) != null) {
                    if (inputLine.startsWith("HTTP") &&
                        inputLine.indexOf("200") >= 0)
                        successful = true;
                    System.out.println(inputLine);
                System.out.println("UPLOAD FILE " +
                                   (successful ? "SUCCESSFUL" : "FAILED") +
                                   "!!!\n");
       * upload(): upload file to server
          * @throws Exception     if an error occurs.
            public void upload() throws Exception {
                try {
                    SSLSocketFactory factory = getFactory();
                    SSLSocket socket =
                        (SSLSocket)factory.createSocket(getHost(), getPort());
                    PrintWriter out =
                        new PrintWriter(new BufferedWriter(new OutputStreamWriter(socket.getOutputStream())));
                    BufferedReader in =
                        new BufferedReader(new InputStreamReader(socket.getInputStream()));
                    socket.startHandshake();
                    sendRequest(out);
                    readResponse(in);
                    out.close();
                    in.close();
                    socket.close();
                } catch (Exception e) {
                    e.printStackTrace();
                    throw e;
       * main(): main method to start file transfer
          * @param args          command line arguments (property file, see usage())
          * @throws Exception     if an error occurs.
            public static void main(String[] args) throws Exception {
                if (args == null || args.length != 1)
                    usage();
                SSLFileTransfer fileXfer = new SSLFileTransfer();
                fileXfer.init(args[0]);
                fileXfer.upload();
        lRC.setCompletion(ReqCompletion.NORMAL,CompletionText) ;
    }Thanks,
    R

    I believe the OP is aware of this :) -- Re: Oracle 11i - 11.5.10.2 - and Java
    Thanks,
    Hussein

  • Java Concurrent Program - connecting to MS SQL Server

    Hi,
    I hope this is correct forum to post this question.
    I am writing a JCP which will connect to a MS SQL Server DB, pull data from a table and populate this data into a custome table in EBS (R12.1.1) database. But I am facing some issues.
    When I run run this concurrent program from EBS, I get following exception message:
    Wed Aug 08 01:18:04 GMT 2012: In openConection()
    Wed Aug 08 01:18:04 GMT 2012: Before Loading Driver com.microsoft.jdbc.sqlserver.SQLServerDriver
    Wed Aug 08 01:18:04 GMT 2012: openConection() ClassNotFoundException: java.lang.ClassNotFoundException: com.microsoft.jdbc.sqlserver.SQLServerDriver
    Wed Aug 08 01:18:04 GMT 2012: Before Calling processPrintMachineRecords()
    Wed Aug 08 01:18:04 GMT 2012: Exception:: java.lang.NullPointerException
    Wed Aug 08 01:18:04 GMT 2012: In closeSQLServerConnection().......closing JDBC Connection
    Wed Aug 08 01:18:04 GMT 2012: Connection object was null, hence skipping close
    Wed Aug 08 01:18:04 GMT 2012: After Calling processPrintMachineRecords()
    The I read somewhere on internet that I should set CLASSPATH in options field of concurrent program definition. So I provided classpath as follows:
    -cp /rs01/u02/applmgr/utyeb02/apps/apps_st/appl/au/12.0.0/appsborg.zip:/rs01/u02/applmgr/utyeb02/apps/apps_st/comn/java/classes/apps.zip:/rs01/u02/applmgr/utyeb02/apps/apps_st/comn/java/classes/sqljdbc_4.0/enu/sqljdbc.jar
    In this classpath sqljdbc.jar contains the classes for connecting to MS SQL Server DB. However after giving classpath like this I started getting different error:
    Exception in thread "main" java.lang.NoClassDefFoundError: oracle/apps/fnd/cp/request/Run
    Caused by: java.lang.ClassNotFoundException: oracle.apps.fnd.cp.request.Run
         at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
         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:276)
         at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
         at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
    It appears from the error message that after giving this CLASSPATH, program was not able to find the "Run" method itself. In otherwords, CLASSPATH screwed it further.
    Can anybody please point out what am I doing wrong here?
    Regards
    Java Code:
    package oracle.apps.custom.printmachine;
    import java.sql.*;
    import oracle.apps.fnd.cp.request.* ;
    import java.io.*;
    import oracle.apps.fnd.util.*;
    public class PrintMachineInterface implements JavaConcurrentProgram {
    public static final String M_SUCCESS = "SUCCESS";
    public static final String M_ERROR = "ERROR";
    public static final String M_WARNING = "WARNING";
    int mRequestStatus = -1;
    int max_number_of_records = 99999999;
    private String mSqlServerHost = "mysqlserver.domain.com";
    // Application Short Name
    private String applName;
    CpContext mCtx;
    LogFile logFile;
    OutFile outFile;
    Connection mConn = null;
    ReqCompletion lRC;
    public PrintMachineInterface(){
    // if no parameter value is specified for APPLNAME then use FND
    //as default value
    applName = "FND";
    private void logMessage(String str) {
    java.util.Date now = new java.util.Date();
    logFile.writeln(now.toString() + ": " + str, LogFile.STATEMENT);
    static String mInsertRecord = " Declare " + " BEGIN "
    + " INSERT INTO XXGFN_GBL_CE_PM_STAGE(ID, KEY, FILENAME, PRINTED_AT, CREATED_AT, DOCTYPE, LANGUAGE, OU, TRX_ID, DOC_ID, REQ_ID, TEMPLATE, PAGES, DOC_TEXT, TIMES_RECEIVED)"
    + " VALUES (:1, :2, :3, :4, :5, :6, :7, :8, :9, :10, :11, :12, :13, substr(:14,2000), :15);"
    + " COMMIT;"
    + " END;";
    static Connection con = null;
    public void openConection() {
    logMessage( "In openConection()");
    try {
    logMessage( "Before Loading Driver com.microsoft.jdbc.sqlserver.SQLServerDriver");
    Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
    logMessage( "After Loading Driver com.microsoft.jdbc.sqlserver.SQLServerDriver");
    logMessage( "Attempting to connect to " + mSqlServerHost);
    con = DriverManager.getConnection("jdbc:microsoft:sqlserver://" + mSqlServerHost + ":1433;User=sql_user;Password=sql_pwd");
    logMessage( "After con assigned from getConnection(jdbc:microsoft:sqlserver://" + mSqlServerHost + ":1433;User=pm_dba_access;Password=*****");
    } catch (java.lang.ClassNotFoundException e) {
    logMessage("openConection() ClassNotFoundException: " + e);
    } catch (SQLException ex) {
    logMessage("openConection() SQLException: " + ex);
    public void closeSQLServerConnection() {
    try {
    logMessage( "In closeSQLServerConnection().......closing JDBC Connection");
    if (con != null)
    logMessage( "Con is not null");
    con.close();
    logMessage( "Con Closed Successfully");
    else
    logMessage( "Connection object was null, hence skipping close");
    } catch (SQLException ex) {
    logMessage("SQLException: " + ex);
    } catch (Exception ex) {
    logMessage("Exception in closeSQLServerConnection() : " + ex);
    private void populate_staging_table(
    String p_id,
    String p_key,
    String p_filename,
    String p_printed_at,
    String p_created_at,
    String p_doctype,
    String p_language,
    String p_ou,
    String p_trx_id,
    String p_doc_id,
    String p_req_id,
    String p_template,
    String p_pages,
    String p_doc_text,
    String p_times_received
    PreparedStatement lStmt = null;
    logMessage("Populating data from PrintMachine history table");
    try {
    lStmt = mConn.prepareCall(mInsertRecord);
    lStmt.setString(1, p_id);
    lStmt.setString(2, p_key);
    lStmt.setString(3, p_filename);
    lStmt.setString(4, p_printed_at);
    lStmt.setString(5, p_created_at);
    lStmt.setString(6, p_doctype);
    lStmt.setString(7, p_language);
    lStmt.setString(8, p_ou);
    lStmt.setString(9, p_trx_id);
    lStmt.setString(10, p_doc_id);
    lStmt.setString(11, p_req_id);
    lStmt.setString(12, p_template);
    lStmt.setString(13, p_pages);
    lStmt.setString(14, p_doc_text);
    lStmt.setString(15, p_times_received);
    lStmt.execute();
    lStmt.close();
    } catch (SQLException s) {
    logMessage("Exception thrown w/ error message: "
    + s.getMessage());
    s.printStackTrace();
    finally {
    try {
    if (lStmt != null)
    lStmt.close();
    } catch (SQLException e) {
    logMessage("SQLException: " + e);
    private void processPrintMachineRecords() {
    int number_of_recs = 0;
    try {
    PreparedStatement stmt = con.prepareStatement("SELECT TOP 1000 ID, Key, Filename, PrintedAt, CreatedAt, Doctype, Language,OU, TransactionID, DocumentID, RequestID, Template, Pages, Documenttext, TimesReceived FROM PM_DATA.dbo.History" );
    ResultSet rst = stmt.executeQuery();
    while (rst.next()) {
    number_of_recs++;
    if (number_of_recs == max_number_of_records) break;
    populate_staging_table(
    rst.getString(1), rst.getString(2)
    ,rst.getString(3), rst.getString(4)
    ,rst.getString(5), rst.getString(6)
    ,rst.getString(7), rst.getString(8)
    ,rst.getString(9), rst.getString(10)
    ,rst.getString(11), rst.getString(12)
    ,rst.getString(13), rst.getString(14)
    ,rst.getString(15)
    stmt.close();
    rst.close();
    mConn.commit();
    } catch (SQLException ex) {
    logMessage("SQLException: " + ex);
    catch (Exception ex) {
    logMessage("Exception:: " + ex);
    closeSQLServerConnection();
    public void runProgram(CpContext pCpContext) {
    applName = "XXGFN";
    String l_file_path = null;
    mCtx = pCpContext;
    //get handle on request completion object for reporting status
    lRC = pCpContext.getReqCompletion();
    // assign logfile
    logFile = pCpContext.getLogFile();
    // assign outfile
    outFile = pCpContext.getOutFile();
    // get the JDBC connection object
    mConn = pCpContext.getJDBCConnection();
    l_file_path = ((new File(outFile.getFileName())).getParent() == null ? ""
    : (new File(outFile.getFileName())).getParent());
    // get parameter list object from CpContext
    ParameterList lPara = pCpContext.getParameterList();
    while (lPara.hasMoreElements())
    NameValueType aNVT = lPara.nextParameter();
    if ( aNVT.getName().equals("APPLNAME") )
    applName = aNVT.getValue();
    /** openConection() Opens the connection to SQL Server Database*/
    openConection() ;
    logMessage("Before Calling processPrintMachineRecords()");
    processPrintMachineRecords();
    logMessage("After Calling processPrintMachineRecords()");
    try{
    setCompletion(ReqCompletion.NORMAL, "Request Completed Normal");
    } catch (Exception e) {
    setCompletion(ReqCompletion.ERROR, e.toString());
    } finally {
    pCpContext.releaseJDBCConnection();
    * Sets the request completion status based on proper precedence. ERROR >
    * WARNING > NORMAL
    * @param pStatus
    * Status of the request.
    * @param pCompletionText
    * Request's completion text.
    public void setCompletion(int pStatus, String pCompletionText) {
    if ((pStatus == ReqCompletion.ERROR)
    || ((pStatus == ReqCompletion.WARNING) && (mRequestStatus != ReqCompletion.ERROR))
    || ((pStatus == ReqCompletion.NORMAL)
    && (mRequestStatus != ReqCompletion.WARNING) && (mRequestStatus != ReqCompletion.ERROR))) {
    mRequestStatus = pStatus;
    lRC.setCompletion(pStatus, pCompletionText);
    }

    ok
    i used Template.java as input
    useful MOS:
    How To Create a Java Concurrent Program? [ID 827563.1]
    Java Concurrent Program FAQ [ID 827575.1]
    i used
    //goto ms sql server 2008r2       
            try{
             Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");        
             con = java.sql.DriverManager.getConnection( 
                                          "jdbc:sqlserver://1.2.3.4:1433;databaseName=test;selectMethod=cursor", 
                                          "test", "test");          
              if(con!=null) System.out.println("Connection Successful!");
            }catch(Exception e){
              e.printStackTrace();
              System.out.println("Error Trace in getConnection() : " + e.getMessage());
            }1.2.3.4 - ip of instance with sqlserver2008r2 :)
    in your code
    >
    try {
    logMessage( "Before Loading Driver com.microsoft.jdbc.sqlserver.SQLServerDriver");
    Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
    logMessage( "After Loading Driver com.microsoft.jdbc.sqlserver.SQLServerDriver");
    logMessage( "Attempting to connect to " + mSqlServerHost);
    con = DriverManager.getConnection("jdbc:microsoft:sqlserver://" + mSqlServerHost + ":1433;User=sql_user;Password=sql_pwd");
    logMessage( "After con assigned from getConnection(jdbc:microsoft:sqlserver://" + mSqlServerHost + ":1433;User=pm_dba_access;Password=*****");
    } catch (java.lang.ClassNotFoundException e) {
    logMessage("openConection() ClassNotFoundException: " + e);
    } catch (SQLException ex) {
    logMessage("openConection() SQLException: " + ex);
    >
    try my case for Driver and Connection
    put result .class file to needed directory
    put sqljdbc4.jar to /rs01/u02/applmgr/utyeb02/apps/apps_st/comn/java/lib
    and for concurrent program option
    -classpath /rs01/u02/applmgr/utyeb02/apps/apps_st/comn/java/classes:/rs01/u02/applmgr/utyeb02/apps/apps_st/appl/au/12.0.0/appsborg.zip:/rs01/u02/applmgr/utyeb02/apps/apps_st/comn/java/lib/sqljdbc4.jaralso useful mos:
    Classpath Setting of Third Party Jar Files in R12 Java Concurrent Program (JCP) [ID 1292694.1]

  • Java RMI program error

    Dear friends,
    I am running an RMI example program,
    have used rmic to generate the stub and skeleton class, have used rmiregistry 1010 to start registry service, and used java Pi to start the server, but there are errors generated as follows,
    Error --java.rmi.UnknownHostException: Unknown host:Default; nested exception is:
    java.net.UnknownHostException:Default
    java.rmi.UnknownHostException: Unknown host:Default; nested exception is:
    java.net.UnknownHostException:Default
    java.net.UnknownHostException:Default
    at java.net.InetAddress.getAllByName0(Unknown Source)
    at java.net.InetAddress.getAllByName0(Unknown Source)
    at java.net.InetAddress.getByName(Unknown Source)
    at java.net.Socket.<init>(Unknow Source)
    at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(Unknow Source)
    at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(Unknow Source)
    at sun.rmi.transport.tcp.TCPEndpoint.newSocket(Unknow Source)
    at sun.rmi.transport.tcp.TCPChannel.createConnection(Unknow Source)
    at sun.rmi.transport.tcp.TCPChannel.newConnection(Unknow Source)
    at sun.rmi.server.UnicastRef.newCall(Unknow Source)
    at sun.rmi.registry.Registry_Stub.bind(Unknow Source)
    at java.rmi.Naming.bind(Unknown Source)
    at Pi.main(Pi.java:23)
    the program codes are as follows,
    //server interface
    import java.rmi.*;
    interface PiRemote extends Remote {
    double getPi() throws RemoteException;
    //server
    import java.net.*;
    import java.rmi.*;
    import java.rmi.registry.*;
    import java.rmi.server.*;
    public class Pi extends UnicastRemoteObject
    implements PiRemote {
    public double getPi() throws RemoteException {
    return Math.PI;
    public Pi() throws RemoteException {
    public static void main(String[] arguments) {
    System.setSecurityManager(new
    RMISecurityManager());
    try {
    Pi p = new Pi();
    Naming.bind("//Default:1010/Pi", p);
    } catch (Exception e) {
    System.out.println("Error -- " +
    e.toString());
    e.printStackTrace();
    //client
    import java.rmi.*;
    import java.rmi.registry.*;
    public class OutputPi {
    public static void main(String[] arguments) {
    System.setSecurityManager(
    new RMISecurityManager());
    try {
    PiRemote pr =
    (PiRemote)Naming.lookup(
    "//Default:1010/Pi");
    for (int i = 0; i < 10; i++)
    System.out.println("Pi = " + pr.getPi());
    } catch (Exception e) {
    System.out.println("Error -- " + e.toString());
    e.printStackTrace();
    who know how to resolve the problem, thank you in advance:)

    I do always use the ip adress/port
    You can find it by
    try {
         ipLocal = InetAddress.getLocalHost();
         catch(Exception e) {
              new PopUpMessage("ERROR","Error in searching IP", true);
    system.out.println("Your IP address is " + ipLocal.getHostAddress());

  • �� I have a java applet program (yanhua.java) need help!!!

    �� I have a java applet program (yanhua.java) that use mouse click a area show a fireworks, the applet program that a java fan mail me. Now i find some bug in the program, can you help me? thank in advance!
    The backdrop of the question: The yanhua.java applet program works well. But one day, i install j2re 1.4.1 plugin for my microsfot Internet Explorer, i run the yanhua.java applet program again, it show difficult(i move my mouse in the area, slowness), the fireworks is not fluent. Then i try my best to find the cause , i get some information, the following: yanhua.java run in j2re 1.4.1 plugin,it will deplete 100% cpu; else yanhua.java does not run in j2re 1.4.1 plugin, it will deplete 90%--95% cpu too; but my computer c3 1G cpu and 256MB memory, without running other program at that time. So i can have the assurance to say that the yanhua.java have some bug or error. can you help me to find all bug in yanhua.java? thank you very much!!!
    i want to solve the question: finding all bug in yanhua.java
    NOTE:
    1��fireworks show specially good effect(a yanhua.java applet) you can look at:
    http://www.3ren.net/down/java/yanhua.html
    2��all program you can get from http://www.3ren.net/down/java/yanhua.rar
    /*************************yanhua.java******************************
    import java.applet.Applet;
    import java.applet.AudioClip;
    import java.awt.*;
    import java.awt.image.MemoryImageSource;
    import java.util.Random;
    public class yanhua extends Applet
    implements Runnable
    private int m_nAppX;
    private int m_nAppY;
    private int m_centerX;
    private int m_centerY;
    private int m_mouseX;
    private int m_mouseY;
    private int m_sleepTime;
    private boolean isError;
    private boolean m_isPaintFinished;
    boolean isRunning;
    boolean isInitialized;
    Thread runner;
    int pix0[];
    MemoryImageSource offImage;
    Image dbImg;
    int pixls;
    int pixls2;
    Random rand;
    int bits;
    double bit_px[];
    double bit_py[];
    double bit_vx[];
    double bit_vy[];
    int bit_sx[];
    int bit_sy[];
    int bit_l[];
    int bit_f[];
    int bit_p[];
    int bit_c[];
    int bit_max;
    int bit_sound;
    int ru;
    int rv;
    AudioClip sound1;
    AudioClip sound2;
    public yanhua()
    m_mouseX = 0;
    m_mouseY = 0;
    m_sleepTime = 5;
    isError = false;
    isInitialized = false;
    rand = new Random();
    bits = 10000;
    bit_px = new double[bits];
    bit_py = new double[bits];
    bit_vx = new double[bits];
    bit_vy = new double[bits];
    bit_sx = new int[bits];
    bit_sy = new int[bits];
    bit_l = new int[bits];
    bit_f = new int[bits];
    bit_p = new int[bits];
    bit_c = new int[bits];
    ru = 50;
    rv = 50;
    public void init()
    String s = getParameter("para_bits");
    if(s != null)
    bits = Integer.parseInt(s);
    s = getParameter("para_max");
    if(s != null)
    bit_max = Integer.parseInt(s);
    s = getParameter("para_blendx");
    if(s != null)
    ru = Integer.parseInt(s);
    s = getParameter("para_blendy");
    if(s != null)
    rv = Integer.parseInt(s);
    s = getParameter("para_sound");
    if(s != null)
    bit_sound = Integer.parseInt(s);
    m_nAppX = this.getSize().width;
    m_nAppY = this.getSize().height;
    m_centerX = m_nAppX / 2;
    m_centerY = m_nAppY / 2;
    m_mouseX = m_centerX;
    m_mouseY = m_centerY;
    resize(m_nAppX, m_nAppY);
    pixls = m_nAppX * m_nAppY;
    pixls2 = pixls - m_nAppX * 2;
    pix0 = new int[pixls];
    offImage = new MemoryImageSource(m_nAppX, m_nAppY, pix0, 0, m_nAppX);
    offImage.setAnimated(true);
    dbImg = createImage(offImage);
    for(int i = 0; i < pixls; i++)
    pix0[i] = 0xff000000;
    sound1 = getAudioClip(getDocumentBase(), "firework.au");
    sound2 = getAudioClip(getDocumentBase(), "syu.au");
    for(int j = 0; j < bits; j++)
    bit_f[j] = 0;
    isInitialized = true;
    start();
    public void run()
    while(!isInitialized)
    try
    Thread.sleep(200L);
    catch(InterruptedException interruptedexception) { }
    do
    for(int j = 0; j < pixls2; j++)
    int k = pix0[j];
    int l = pix0[j + 1];
    int i1 = pix0[j + m_nAppX];
    int j1 = pix0[j + m_nAppX + 1];
    int i = (k & 0xff0000) >> 16;
    int k1 = ((((l & 0xff0000) >> 16) - i) * ru >> 8) + i;
    i = (k & 0xff00) >> 8;
    int l1 = ((((l & 0xff00) >> 8) - i) * ru >> 8) + i;
    i = k & 0xff;
    int i2 = (((l & 0xff) - i) * ru >> 8) + i;
    i = (i1 & 0xff0000) >> 16;
    int j2 = ((((j1 & 0xff0000) >> 16) - i) * ru >> 8) + i;
    i = (i1 & 0xff00) >> 8;
    int k2 = ((((j1 & 0xff00) >> 8) - i) * ru >> 8) + i;
    i = i1 & 0xff;
    int l2 = (((j1 & 0xff) - i) * ru >> 8) + i;
    int i3 = ((j2 - k1) * rv >> 8) + k1;
    int j3 = ((k2 - l1) * rv >> 8) + l1;
    int k3 = ((l2 - i2) * rv >> 8) + i2;
    pix0[j] = i3 << 16 | j3 << 8 | k3 | 0xff000000;
    rend();
    offImage.newPixels(0, 0, m_nAppX, m_nAppY);
    try
    Thread.sleep(m_sleepTime);
    catch(InterruptedException interruptedexception1) { }
    } while(true);
    public void update(Graphics g)
    paint(g);
    public void paint(Graphics g)
    g.drawImage(dbImg, 0, 0, this);
    public void start()
    if(isError)
    return;
    isRunning = true;
    if(runner == null)
    runner = new Thread(this);
    runner.start();
    public void stop()
    if(runner != null)
    runner.stop();
    runner = null;
    public boolean mouseMove(Event event, int i, int j)
    m_mouseX = i;
    m_mouseY = j;
    return true;
    public boolean mouseDown(Event event, int i, int j)
    m_mouseX = i;
    m_mouseY = j;
    int k = (int)(rand.nextDouble() * 256D);
    int l = (int)(rand.nextDouble() * 256D);
    int i1 = (int)(rand.nextDouble() * 256D);
    int j1 = k << 16 | l << 8 | i1 | 0xff000000;
    int k1 = 0;
    for(int l1 = 0; l1 < bits; l1++)
    if(bit_f[l1] != 0)
    continue;
    bit_px[l1] = m_mouseX;
    bit_py[l1] = m_mouseY;
    double d = rand.nextDouble() * 6.2800000000000002D;
    double d1 = rand.nextDouble();
    bit_vx[l1] = Math.sin(d) * d1;
    bit_vy[l1] = Math.cos(d) * d1;
    bit_l[l1] = (int)(rand.nextDouble() * 100D) + 100;
    bit_p[l1] = (int)(rand.nextDouble() * 3D);
    bit_c[l1] = j1;
    bit_sx[l1] = m_mouseX;
    bit_sy[l1] = m_nAppY - 5;
    bit_f[l1] = 2;
    if(++k1 == bit_max)
    break;
    if(bit_sound > 1)
    sound2.play();
    return true;
    public boolean mouseExit(Event event, int i, int j)
    m_mouseX = i;
    m_mouseY = j;
    return true;
    void rend()
    boolean flag = false;
    boolean flag1 = false;
    boolean flag2 = false;
    for(int k = 0; k < bits; k++)
    switch(bit_f[k])
    default:
    break;
    case 1: // '\001'
    bit_vy[k] += rand.nextDouble() / 50D;
    bit_px[k] += bit_vx[k];
    bit_py[k] += bit_vy[k];
    bit_l[k]--;
    if(bit_l[k] == 0 || bit_px[k] < 0.0D || bit_py[k] < 0.0D || bit_px[k] > (double)m_nAppX || bit_py[k] > (double)(m_nAppY - 3))
    bit_c[k] = 0xff000000;
    bit_f[k] = 0;
    } else
    if(bit_p[k] == 0)
    if((int)(rand.nextDouble() * 2D) == 0)
    bit_set((int)bit_px[k], (int)bit_py[k], -1);
    } else
    bit_set((int)bit_px[k], (int)bit_py[k], bit_c[k]);
    break;
    case 2: // '\002'
    bit_sy[k] -= 5;
    if((double)bit_sy[k] <= bit_py[k])
    bit_f[k] = 1;
    flag2 = true;
    if((int)(rand.nextDouble() * 20D) == 0)
    int i = (int)(rand.nextDouble() * 2D);
    int j = (int)(rand.nextDouble() * 5D);
    bit_set(bit_sx[k] + i, bit_sy[k] + j, -1);
    break;
    if(flag2 && bit_sound > 0)
    sound1.play();
    void bit_set(int i, int j, int k)
    int l = i + j * m_nAppX;
    pix0[l] = k;
    /*********************************end*******************************

    no one help me???????????

  • Facing error wen running Java Concurrent Program to insert data into  table

    Hi All,
    Its first time I am wrkng on Java Concurrent Programs. I created a java class with the below code:
    import oracle.apps.fnd.cp.request.*;
    import oracle.apps.iby.scheduler.*;
    import java.sql.*;
    import java.sql.Statement;
    import java.sql.Connection;
    import oracle.apps.fnd.common.VersionInfo;
    import oracle.apps.fnd.cp.request.CpContext;
    import oracle.apps.fnd.cp.request.JavaConcurrentProgram;
    import oracle.apps.iby.database.DBWrapper;
    import oracle.apps.iby.ecapp.OraPmt;
    import oracle.apps.iby.exception.Log;
    import oracle.apps.iby.security.SecurityUtil;
    //package oracle.apps.ibe.util.key;
    //package oracle.apps.iby.scheduler;
    // Referenced classes of package oracle.apps.iby.scheduler:
    // SchedUtils
    public class XXIBE_KeyInsert
    implements JavaConcurrentProgram
    public XXIBE_KeyInsert()
    public void runProgram(CpContext cpcontext)
    try{
    String s;
    oracle.apps.fnd.cp.request.ReqCompletion reqcompletion;
    Connection connection;
    // s = "iby.scheduler.XXIBE_keyInsert.runProgram";
    reqcompletion = cpcontext.getReqCompletion();
    connection = null;
    OraPmt.init(cpcontext);
    Log.debug("Inserting Credit Card key", 1, "XXIBE_KeyInsert.java");
    byte abyte0[] = SecurityUtil.getSystemKey();
    connection = cpcontext.getJDBCConnection();
    Statement st = connection.createStatement();
    String sql = "Insert into xxibe_scodes values ("+abyte0+")";
    st.executeUpdate(sql);
    connection.commit();
    st.close();
    connection.close();
    Log.debug("done", 1, "XXIBE_KeyInsert.java");
    reqcompletion.setCompletion(reqcompletion.NORMAL, "Request Completed Normal");
    OraPmt.end();
    SchedUtils.setSuccess(reqcompletion);
    DBWrapper.closeDBConnection(connection);
    catch(Exception e){
    e.printStackTrace();
    //reqcompletion.setCompletion(ReqCompletion.ERROR, e.toString());
    I compiled the program and in the java_top/oracle/apps/../.. (in the pkg given). Now the class files and java files are in the said location. I created an executable of type "java concurent Prog" and location same as Package name.
    Created a Program and assigned it to the responsibility. Having done this when i run the CP I find it ends with an error msg. The log files show the below exceptions: "java.lang.ClassNotFound Exception".
    We are doing it in R12.0.6 and in Unix server. Pls help me where I am missing it. It turned to be an urgent requirement frm my end.
    Thanks,
    Abhishek.

    The Exception Stack is :
    java.lang.ClassNotFoundException: oracle.apps.iby.scheduler.test.XXIBE_KeyInsert
         at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
         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)
         at java.lang.Class.forName0(Native Method)
         at java.lang.Class.forName(Class.java:164)
         at oracle.apps.fnd.cp.request.Run.main(Run.java:152).
    Please advice me on how to proceed.

  • Java chat programs

    hi..am looking for sample java programs where a server can communicate to multiple clients and viseversa....could anyone by any chance have done similar programs or knows a link to such programs?
    thanks
    ps:i already checked in the forum and found a number of incomplete codes..so i'm looking for something complete.

    It doesn't follow any naming convention as i wrote it a long time back when ( I didn't know what coding conventions were then). However it will give you a basic idea
    The server code
         import java.io.*;
         import java.net.*;
         class kserverreceive implements Runnable
              Socket client1;
              BufferedReader in;
              String fromuser;
              Thread t;
              kserverreceive(Socket client1,BufferedReader in)
                   this.client1=client1;
                   this.in=in;
                   t=new Thread(this);
                   t.start();
              public void run()
                   try
                        while((fromuser=in.readLine())!=null)
                             System.out.println(fromuser);
                   catch(IOException e)
                        System.out.println("IOException encountered");
              //System.out.println("client has disconnected");
         class kserversend implements Runnable
              Socket client2;
              BufferedReader stdIN=new BufferedReader(new InputStreamReader(System.in));
              PrintWriter out;
              String touser;
              Thread t;
              kserversend(Socket client2,PrintWriter out)
                   this.client2=client2;
                   this.out=out;
                   t=new Thread(this);
                   t.start();
              public void run()
                   try
                        while((touser=stdIN.readLine())!=null)
                             out.println(touser);
                   catch(IOException e)
                        System.out.println("IOException encountered");
              //System.out.println("the client has disconneceted");
         public class kserver
              public static void main(String args[]) throws IOException
                   ServerSocket server=null;
                   Socket client=null;
                   BufferedReader in;
                   PrintWriter out;
                   kserverreceive client1;
                   kserversend client2;
                   try
                        server=new ServerSocket(7777);
                   catch(IOException e)
                        System.out.println("couldnt listen on port 7777");
                        System.exit(1);
                   try
                        while(true)
                             client=server.accept();
                             in=new BufferedReader(new InputStreamReader(client.getInputStream()));
                             out=new PrintWriter(client.getOutputStream(),true);
                             System.out.println("connection established");
                             client2=new kserversend(client,out);
                             client1=new kserverreceive(client,in);                    
                   catch(Exception e)
                        System.out.println("accept failed:"+e);
                        System.exit(1);
                   //This is if you want to accept only a single client request
                   /*String outline;
                   BufferedReader inread=new BufferedReader(new InputStreamReader(client.getInputStream()));
                   while((outline=inread.readLine())!=null)
                        System.out.println(outline);
    //               inread.close();
                   client.close();
                   server.close();
              The client code
         import java.io.*;
         import java.net.*;
         class kclientsend implements Runnable
              Socket client1;
              PrintWriter out;
              Thread t;
              String touser;
              BufferedReader stdIN=new BufferedReader(new InputStreamReader(System.in));
              kclientsend(Socket client1,PrintWriter out)
                   this.client1=client1;
                   this.out=out;
                   t=new Thread(this);
                   t.start();
              public void run()
                   try
                        while((touser=stdIN.readLine())!=null)
                             out.println(touser);
                   catch(IOException e)
                        System.out.println("IOException encountered");
              //System.out.println("The client has disconnected");
         class kclientreceive implements Runnable
              Socket client2;
              BufferedReader in;
              String fromuser;
              Thread t;          
              kclientreceive(Socket client2,BufferedReader in)
                   this.in=in;
                   this.client2=client2;               
                   t=new Thread(this);
                   t.start();
              public void run()
                   try
                        while((fromuser=in.readLine())!=null)
                             System.out.println("["+client2.getInetAddress().toString()+"]::"+client2.getInetAddress().getHostName()+"::"+fromuser);
                   catch(IOException e)
                        System.out.println("IOException encountered");
              //System.out.println("The client has disconnected");
         public class kclient
              public static void main(String args[]) throws Exception
                   Socket client=null;
                   PrintWriter out=null;
                   BufferedReader in=null;
                   kclientsend client1;
                   kclientreceive client2=null;
                   try
                        client=new Socket("NAMI",7777);
                        out=new PrintWriter(client.getOutputStream(),true);
                        in=new BufferedReader(new InputStreamReader(client.getInputStream()));
                        System.out.println("connection established successfully");
                        client1=new kclientsend(client,out);
                        client2=new kclientreceive(client,in);
                   catch(UnknownHostException e)
                        System.out.println("NAMI not found"+e);
                        System.exit(1);
                   catch(IOException e)
                        System.out.println("couldnt get IO for NAMI"+e);
                        System.exit(1);
                   /*String fromuser;
                   BufferedReader stdIN=new BufferedReader(new InputStreamReader(System.in));
                   while((fromuser=stdIN.readLine())!=null)
                        out.println(fromuser);
                   Thread.sleep(100000);
                   out.close();
                   // stdIN.close();
                   client.close();
                   Message was edited by:
    qUesT_foR_knOwLeDge

  • Calling Dot Net program From oracle Database

    Hi
    is there any way to call DOT NET program Like C# from oracle database, i mean is there way to call it from pl-sql stored procedure or trigger ..etc
    I read that is possible with java , C, C++, but is it possible with C#
    Best Regards

    If your Oracle database is running on Windows and is a reasonably recent version (I believe 10.1 or later), it has the ability to create .Net stored procedures just like you have the ability to create Java stored procedures. That tends not to be a particularly commonly used feature but it's an option. If you compile your .Net application to a DLL, you could also call it as an external procedure.
    More commonly, however, if you're talking about a .Net program that is deployed on a middle tier server, however, would be for the .Net application to expose an API (say, a web service API) that the database could invoke (via UTL_DBWS or UTL_HTTP).
    Justin

  • MAC OS 10.5.7 FireWall & Java Socket programing

    Hi everyone,
    I am fighting for few days with a simple problem in vain.
    I am programming a simple java client-server application based on TCP sockets but I do not manage to open any socket at all due to a "connection refused" problem:
    In the previous versions of MAC OS X Leopard it was possible to open communication port easily. The latest version of leopard no longer support this functionality. Now you can grant permission only to applications (not to java programs).
    I tried the following:
    Creating a script that starts my application and uses the firewall setup program to grant permission to that script: Impossible only application can be managed neither script nor JAR files are accepted.
    Modifying low level firewall parameters using IPFW: useless the MAC firewall works at a lower level. changing local firewall rules does change anything.
    I am thinking about modifying the /library/Java/Home/lib/java.security file but I think that it works only for Applets.
    I try to grant permissions to the java executable file using the firewall configuration panel but the problem is still present.
    I am sure that lots of programers had this problem.. Anyone have a simple solution ?
    Thx for your time.
    PS: here a simple code example of what I am doing.
    try
    socket = new Socket(InetAddress.getLocalHost(),port);
    catch (UnknownHostException e)
    e.printStackTrace();
    and the output is:
    java.net.ConnectException: Connection refused

    I finally got around to rearranging and backing up partitions. Updated to 10.5.7 on a non live partition and then booted into it. Don't have any problems with CS3 ID, IL or PS. And no problem with CS4 ID, IL, PS. Does appear to have fixed the OpenGL problems with the NVIDIA GeForce 8800 GT video card and PSCS4. I will say on the main workstations I have not updated a live booted partition in years. Seems like there are nothing but problem trying to update a live partition.
    As to the monitor profile being introduced into the RGB print flow from ID PS3 and 4. Problem still there and still not fixed. But of course you can use Print as Bitmap or if your running a Canon printer with selectable Fast Graphic Process in the driver you can print correct output this way.

  • Java Card program execution on Eclipse

    Hi Dears,
    I am new to Java Card. I did setup to run Java Card programs on eclipse using http://eclipse-jcde.sourceforge.net/.
    This is my simple program below
    import javacard.security.RandomData;
    public class Main {
         public void main() {
              RandomData rd = RandomData.getInstance(RandomData.ALG_SECURE_RANDOM);
              short outLen = 10;
              byte buffer[] = new byte[outLen];
              short outOffset = 0;
              rd.generateData(buffer, outOffset, outLen);
    Compilation is successful but when I run the program I get the following error.
    Error occurred during initialization of VM
    java/lang/NoClassDefFoundError: java/lang/String
    This is very annoying. I think my run time environment is not ok for running java card programs. I am able to run Java programs but not java card programs. Any one can help please?
    Thanks,
    Regards,
    Naveed

    please post code with &#123;code} tags
    Naveed86 wrote:
    Hi Dears,
    I am new to Java Card. I did setup to run Java Card programs on eclipse using http://eclipse-jcde.sourceforge.net/.
    This is my simple program below
    import javacard.security.RandomData;
    public class Main {
         public void main() {
              RandomData rd = RandomData.getInstance(RandomData.ALG_SECURE_RANDOM);
              short outLen = 10;
              byte buffer[] = new byte[outLen];
              short outOffset = 0;
              rd.generateData(buffer, outOffset, outLen);
    }Compilation is successful but when I run the program I get the following error.
    Error occurred during initialization of VM
    java/lang/NoClassDefFoundError: java/lang/String
    This is very annoying. I think my run time environment is not ok for running java card programs. I am able to run Java programs but not java card programs. Any one can help please?
    Thanks,
    Regards,
    Naveed

Maybe you are looking for

  • Need a report with po,gr,ir values in LC and FC

    Dear experts, How can I develop this custom report  with po,gr,ir values in LC and FC with the following fields is their any standard sap report .Please advise PO NO PO DATE GRNO GR DT IR NO IR DATE VENDOR GR VALUE IR VALUE GR VALUE IN FC IR VALUE IN

  • First PKGBUILD, Faulty when Installed by Pacman?

    I'm trying to package this: Enigma-dev (git) http://enigma-dev.org/ I'm having a problem with it when it gets installed by pacman, where it tries to compile itself again.. PKGBUILD: pkgname=enigma-dev-git pkgver=0.0.0 pkgrel=1 pkgdesc="ENIGMA, the Ex

  • Problem with printing ALV - repetitive page breaks

    Hi, I have a problem with ALV during printing or print preview. First, let me describe the situation. My requirement was to have a page break for every Material Number. This was working fine already. However, the user had a change of heart and decide

  • Blog entry template type?

    I want to change hyperlink colors in my blog entries. I followed the excellent instructions I found here and edited the blog template to make the hyperlinks blue. But only the links on the main blog page were affected. Which template do I have to edi

  • Where is acl_employees.zip?

    I am wondering if anybody knows why the link provided under the How to Build an Access Control Page Download Spreadsheet Data Download the following *.csv file to your local system: In your Web browser go to: http://www.oracle.com/technology/products