Network programming C and Java

Hi
I'm new to writing client/server programs.
I have a solaris box and I have a server written in C.
I like to write a java client to talk to the server.
Are there web sites here or elsewhere that would show
examples of that ?
FULLY Appreciate any help.

jschell
thanks for your response.
I dont quite understand what u mean by definition.
Do you mean the C struct of the message sent ?
DMINT32 is the regular primitive data type
long int
my C server header file contains:
extern struct empm_rec_struct {
     DMINT32 ml;
     DMINT32 lm;
     DMINT32 mm;
     DMINT32 boolean;
     DMINT32 rollover;
} current_empm_rec;
struct empm_rec_struct temp_empm_rec;
/* struct to send to client */
extern struct MsgStruct {
     struct empm_rec_struct msg_rec;
     DMINT32          index;
struct MsgStruct msgStruct;
I then tried sending this struct with send( ):
eg:
i = sprintf(str, "msgstruct ml %d\n",msgStruct.msg_rec.ml);
          if (send(new_fd,str, 10, 0) == -1)
     perror("send");
but my java client only show:
msgstruct
that's why I need an example like mine where the java client sends a "pulse"
to the server, server sends the struct msg and then client prints them out.

Similar Messages

  • Network UI element and Java 8

    Hello everybody!
    We are using the "Network" UI element (JNet) in one of our WD Java applications (NW 7.3.1 SP 11). This element consists of an obviously unsigned Java applet (which my local Java 7 JVM complained about for some time). Anyway the applet was working o.k. and the defnied Graphs were rendered (almost) as expected.
    Today, I updated my local JVM to Java 1.8.0_45. When using my WebDynpro application, my Browser (IE9) shows the applet area with the Java wait logo, then complains about the unsigned applet as before. When I decide to execute the applet anyway, the applet area turns white, then light blue, but nothing else happens. No graph gets rendered. The same behaviour can be seen using Firefox 32.
    The java console essentially shows nothing except the JNet version:
    Java-Plug-in 11.45.2.14
    JRE-Version verwenden 1.8.0_45-b14 Java HotSpot(TM) Client VM
    0
    ACF version: 7.1000.1.07
    JNet 1.1342.15002
    UR L&F version: 7.1000.0.12
    What did I do wrong ? Did anyone come across this behaviour ? Is there any patch available that resolves the "unsigned applet" problem or can we get a newer version of this applet somehow ?
    Regards
    Michael

    Hi Ravi!
    Yes, we added our portal URL to the JVM security exception list when we upgraded the local JVM to Java 7.
    I would like the JNet applet shipped with the WebDynpro runtime to be signed, though, to avoid all these complications. Since the "Network" seems to be an official ui element, I'd expect it to be up to date, to be patched to work with current JVMs and so on. Maybe we missed some notes or patches ?
    Regards
    Michael

  • Related to Network program using Java Client and C server

    I am little bit experience in java technology. I need an urgent help as I have to submit a document related to C server and Java client. But while searching in net i cant get a proper guidance for C server as many errors thrown in sys/socket.h and other new header files. Can any one help me out for giving source code for C Server. so that i can further involve in that document. Please help me out. i am really helpless by the way the C server thrown error. after finishing that C server only i can concentrate on Java client...

    Hai Josah,
    Thanks for your reply.. I have gone through many sockets server program in C but the real proble is the header file they include like
    socket.h and in.h etc.. they also provide these header files but if we compile in turboC they inturn require some other header files. I dont get the full hierarchy of C server program. I found some help in Java programming Archive about C Server and java client. As i am new to C i cant get the full header files for the server.c if i complete taht only i can proceed to java client. If u can redirect me for any good C sites also i can be thankful for u forever..please

  • How to write JDBC code in a java thread? for network programming

    Hii guys, i am new to java network programming. I developed small swing application for stock controlling in a shop, so i need to run the database in a server. i try the peer to peer scenario, but the response is too late and the application get stuck. there i wl put my data base java class
    please help me for this, how can i change this java class to networked JDBC
    import com.mysql.jdbc.Connection;
    import java.sql.DriverManager;
    import java.sql.PreparedStatement;
    import java.sql.ResultSet;
    import java.sql.Statement;
    public class ConnectionSet {
    private String severIp = "localhost";
    private String severPort = "3306";
    private String userName = "root";
    private String password = "123";
    private ResultSet rs;
    public void setSeverIp(String Ip) {
    severIp = Ip;
    public void setSeverPort(String Port) {
    severPort = Port;
    public void SetUserName(String Name) {
    userName = Name;
    public void setPassword(String passWord) {
    password = passWord;
    public ResultSet getResult(String url) throws Exception {
    Class.forName("com.mysql.jdbc.Driver");
    Connection cc = (Connection) DriverManager.getConnection("jdbc:mysql://" + getSeverIp() + ":" + getSeverPort() + "/suriyalanka", getUserName(), getPassword());
    Statement s = cc.createStatement();
    rs = s.executeQuery(url);
    // java.sql.ResultSet rs = (ResultSet) DriverManager.getConnection("jdbc:mysql://"+getSeverIp()+":"+getSeverPort()+"/suriyalanka",getUserName(), getPassword()).createStatement().executeQuery(url);
    return rs;
    public Connection getConnection() throws Exception {
    Class.forName("com.mysql.jdbc.Driver");
    Connection cc = (Connection) DriverManager.getConnection("jdbc:mysql://" + getSeverIp() + ":" + getSeverPort() + "/suriyalanka", getUserName(), getPassword());
    return cc;
    public void setResult(String url) throws Exception {
    Class.forName("com.mysql.jdbc.Driver");
    Connection cc = (Connection) DriverManager.getConnection("jdbc:mysql://" + getSeverIp() + ":" + getSeverPort() + "/suriyalanka", getUserName(), getPassword());
    Statement s = (Statement) cc.createStatement();
    s.executeUpdate(url);
    public String getSeverIp() {
    return severIp;
    public String getSeverPort() {
    return severPort;
    public String getUserName() {
    return userName;
    public String getPassword() {
    return password;
    please help me for this, how can i change this java class to networked JDBC
    Edited by: 798670 on Sep 29, 2010 6:04 AM

    Have you verified that your mysql allows network connections?
    In order to allow network connections you have to comment or remove line "skip-networking" in my.ini(windows) or my.cnf(unix) configuration files of your mysql instance.
    Or if you have the mysql administrator installed
    MySQL Administrator / Startup Variables / Disable networking (uncheck)
    By!

  • Where can I find knowledge about "java network programming"?

    I am interested in network programming in java. I need some documents and I don't where can I find it?

    http://java.sun.com/docs/books/tutorial/networking/index.html

  • Advanced Java network programming

    I have been playing around with the various Server/Client tutorials not only on this site but many others for some time now. Whilst I have learnt a great deal I am now trying to further my knowledge.
    The problem is, there does not seem to be a great deal of information on the Web realting to the advanced network programming stuff. Obviously not having a network of my own I am now interested in learning various ideas using the Internet. Obviously not being a prat about it and port scanning other computers or anything like that.
    I was hoping someone reading this might have a suggestion about where to go next in my learning curve. Also if anyone could recommend any good sources of info for this type of stuff.
    I've currently got three telephone lines in, each line with a seperate Internet account set-up. What I want to do is have them all connected to the web at once and then attempt various things, such as connection, that type of stuff.
    Help really appreciated.
    Thanks,
    kP

    Maybe I'm catching the wrong vibe here, but it seems to me that you need to learn a bit about networking in general, before you worry about how it's all done in java. I would suggest a good basic computer networking text book. After you have good understanding of how different networks works, packet structure of the various common protocols, IP, TCP over IP and UDP over IP. I think the java code to implement it all will just fall into place. my AIM SN is SpinozaQ if you would like a book suggestion. I don't have any names going through my head right now.

  • I am trying to use an education program that needs Java applets to install and use and it will not use Safari. When I download IE from the web it will not install. How can I get a browser that will work on my MacAir for travel use of this program?

    I am trying to use and education program that needs Java applets and it will not run on Safari. IE will not install from the web. How do I get a browser that will work to install so I can use this program when I travel.

    Try using FireFox. IE will only run on a Mac if you run Windows on the Mac.
    Windows on Intel Macs
    There are presently several alternatives for running Windows on Intel Macs.
    Install the Apple Boot Camp software.  Purchase Windows 7 or Windows 8.  Follow instructions in the Boot Camp documentation on installation of Boot Camp, creating Driver CD, and installing Windows.  Boot Camp enables you to boot the computer into OS X or Windows.
    Parallels Desktop for Mac and Windows XP, Vista Business, Vista Ultimate, or Windows 7.  Parallels is software virtualization that enables running Windows concurrently with OS X.
    VM Fusion and Windows XP, Vista Business, Vista Ultimate, or Windows 7.  VM Fusion is software virtualization that enables running Windows concurrently with OS X.
    CrossOver which enables running many Windows applications without having to install Windows.  The Windows applications can run concurrently with OS X.
    VirtualBox is a new Open Source freeware virtual machine such as VM Fusion and Parallels that was developed by Solaris.  It is not as fully developed for the Mac as Parallels and VM Fusion.
    Note that Parallels and VM Fusion can also run other operating systems such as Linux, Unix, OS/2, Solaris, etc.  There are performance differences between dual-boot systems and virtualization.  The latter tend to be a little slower (not much) and do not provide the video performance of the dual-boot system. See MacTech.com's Virtualization Benchmarking for comparisons of Boot Camp, Parallels, and VM Fusion. A more recent comparison of Parallels, VM Fusion, and Virtual Box is found at Virtualization Benchmarks- Parallels 10 vs. Fusion 7 vs. VirtualBox. Boot Camp is only available with Leopard and later. Except for Crossover and a couple of similar alternatives like DarWine you must have a valid installer disc for Windows.
    You must also have an internal optical drive for installing Windows. Windows cannot be installed from an external optical drive.

  • Java plugin doesn't work, even though it's installed correctly and java programs work.

    As stated. I have a link in ~/.mozilla/plugin that points to test/jre/plugin/i386/ns7/libjavaplugin_oji.so, which is the java 6 update 21 runtime environment.
    Java doesn't show in about:plugins, and java applets don't start (firefox suggests to install missing plugins).
    Java programs using the jre outside the browser work.
    This is on Linux 32-bits, Slackware 13.0, kernel 2.6.34.

    <blockquote>As stated. I have a link in ~/.mozilla/plugin that points to test/jre/plugin/i386/ns7/libjavaplugin_oji.so, which is the java 6 update 21 runtime environment.
    </blockquote>
    Where did you read that?<br />
    See http://kb.mozillazine.org/Java<br />
    In Firefox 3.6 and later versions you need the Next-Generation Java™ Plug-In present in Java 6 U10 and later (Linux: libnpjp2.so; Windows: npjp2.dll).
    http://java.com/en/download/faq/firefox_newplugin.xml
    http://java.sun.com/javase/6/webnotes/install/jre/manual-plugin-install-linux.html
    <pre><nowiki>ln -s /usr/local/java/jre1.6.0_20/lib/i386/libnpjp2.so libnpjp2.so
    ln -s /usr/lib/jvm/jre/lib/i386/libnpjp2.so /usr/lib/mozilla/plugins/libnpjp2.so (java-1_6_0-sun-plugin)
    </nowiki></pre>

  • I'm in a java programming class and i'm stuck.. so please help me guys...

    Please help me, i really need help.
    Thanks a lot guys...
    this is my error:
    C:\Temp>java Lab2
    Welcome!
    This program computes the average, the
    exams
    The lowest acceptable score is 0 and th
    Please enter the minimum allowable scor
    Please enter the maximum allowable scor
    Was Exam1taken?
    Please Enter Y N or Q
    y
    Enter the Score for Exam1:
    65
    Was Exam2taken?
    Please Enter Y N or Q
    y
    Enter the Score for Exam2:
    32
    Was Exam3taken?
    Please Enter Y N or Q
    y
    Enter the Score for Exam3:
    65
    Was Exam4taken?
    Please Enter Y N or Q
    y
    Enter the Score for Exam4:
    32
    Was Exam5taken?
    Please Enter Y N or Q
    y
    Enter the Score for Exam5:
    32
    Score for Exam1 is:65
    Score for Exam2 is:32
    Score for Exam3 is:32
    Score for Exam4 is:32
    Score for Exam5 is:32
    the Minimum is:0
    the Maximum is:0
    Can't compute the Average
    Can't compute the Variance
    Can't compute the Standard Deviation
    this is my code:
    // Lab2.java
    // ICS 21 Fall 2002
    // Read in scores for a student's exams, compute statistics on them, and print out
    // the scores and statistics.
    public class Lab2
         // Create a manager for this task and put it to work
         public static void main(String[] args)
              ExamsManager taskManager = new ExamsManager();
              taskManager.createResults();
    // ExamsManager.java for Lab 2
    // ICS 21 Fall 2002
    // make these classes in the Java library available to this program.
    import java.io.BufferedReader;
    import java.io.InputStreamReader;
    import java.io.IOException;
    import java.text.NumberFormat;
    // ExamsManager creates managers and contains the tools (methods) they need to do their
    // job: obtaining exam information, computing statistics and printing out that information
    class ExamsManager
         // INVALID_INT: special integer value to indicate that a non-integer
         // was entered when an integer was requested. It's chosen so as not to
         // conflict with other flags and valid integer values
         public static final int INVALID_INT = -9999;
         // valid user response constants:
         public static final String YES = "Y";               // user responded "yes"
         public static final String NO = "N";               // user responded "no"
         public static final String EXIT_PROGRAM = "Q";     // user responded "leave the program NOW"
         // INVALID_RESPONSE: special String value to indicate that something other than
         // "Y", "N" or "X" was entered when said was required
         public static final String INVALID_RESPONSE = "!";
         // ABSOLUTE_MIN_SCORE and ABSOLUTE_MAX_SCORE represent the smallest
         // minimum score and the largest maximum score allowed by the
         // program. (The allowable minimum and maximum for one
         // execution of the program may be different than these, but
         // they must both lie within this range.)
         public static final int ABSOLUTE_MIN_SCORE = 0;
         public static final int ABSOLUTE_MAX_SCORE = 1000;
         // The manager needs a place to store this student's exams
         private OneStudentsWork thisWork;
         // ...places to store the min and max scores allowed for these exams
         private int minAllowedScore;
         private int maxAllowedScore;
         // ...and a place to hold input coming from the keyboard
         BufferedReader console;
         //                    -------------------- Constructor --------------------
         // ExamsManager() make managers that delegate the major tasks of the program
         public ExamsManager()
         //                    -------------------- Processing methods --------------------
         // createResults() is the "manager at work": it calls assistants to welcome the user,
         // initializes things so we can read info from the keyboard,
         // obtain the minimum and maximum allowed scores,
         // obtain a student's work and comute the statistics on it and
         // print out the scores and the statistics
         public void createResults()
              // *** YOUR CODE GOES HERE ***
              printWelcomeMessage();
              readyKeyboard();
              obtainMinAndMaxAllowedScores();
              obtainOneStudentsWork();
              printResults();
         //                    -------------------- User input methods --------------------
         // readyKeyboard() sets up an input stream object 'console' connected to the keyboard
         // so that what's typed can be read into the program and processed.
         // Do not modify this code!
         private void readyKeyboard()
                   console = new BufferedReader(new InputStreamReader(System.in));
         // obtainMinAndMaxAllowedScores() asks the user to enter the minimum
         // and maximum allowable scores for this execution of the program.
         // Both the minimum and maximum allowable scores must be between
         // ABSOLUTE_MIN_SCORE and ABSOLUTE_MAX_SCORE (inclusive). This
         // method should continue to ask the user for a minimum until a
         // valid one is entered (or EXIT_PROGRAM is entered), then continue
         // to ask the user for a maximum until a valid one is entered. If
         // the minimum entered is greater than the maximum entered, the
         // whole thing should be done again.
         public void obtainMinAndMaxAllowedScores()
              // *** YOUR CODE GOES HERE ***
              int response = INVALID_INT;
              if (response >= minAllowedScore && response <= maxAllowedScore)
                   System.out.print("Please enter the minimum allowable score:");
                   response = getIntOrExit();
              while (response > maxAllowedScore || response < minAllowedScore)
                   System.out.print("Please enter the minimum allowable score:");
                   response = getIntOrExit();
              if (response <= ABSOLUTE_MAX_SCORE && response >= ABSOLUTE_MIN_SCORE)
                   System.out.print("Please enter the maximum allowable score:");
                   response = getIntOrExit();
              while (response > ABSOLUTE_MAX_SCORE || response < ABSOLUTE_MIN_SCORE)
                   System.out.print("Please enter the maximum allowable score:");
                   response = getIntOrExit();
              /*int response;
              String allowedMin;
              boolean done = true;
              do
                   done = true;
                   System.out.print("Please enter the minimum allowable score:");
                   response = getIntOrExit();
                   allowedMin = getYNOrExit();
                   if(allowedMin == EXIT_PROGRAM)
                        System.exit(0);
                   else if (response >= ABSOLUTE_MIN_SCORE)
                        done = true;
                   else if (response >= ABSOLUTE_MAX_SCORE)
                        done = false;
                        System.out.println("INVALID: " + INVALID_INT);
                        System.out.print("Please enter the minimum allowable score:");
                        response = getIntOrExit();
              }while (!done);
    /*          System.out.print("Please enter the maximum allowable score:");
              response = getIntOrExit();
              if (response <= ABSOLUTE_MAX_SCORE)
              return response;
              else if (response <= ABSOLUTE_MIN_SCORE)
                   response = INVALID_INT;
              while (response == INVALID_INT)
                   System.out.print("Please enter the maximum allowable score:");
                   response = getIntOrExit();
              do
                   done = true;
                   System.out.print("Please enter the minimum allowable score:");
                   response = getIntOrExit();
                   String allowedMax;
                   if(allowedMin == EXIT_PROGRAM)
                        System.exit(0);
                   if (response <= ABSOLUTE_MAX_SCORE)
                        done = true;
                   else if (response <= ABSOLUTE_MIN_SCORE)
                        done = false;
                        System.out.println("INVALID: " + INVALID_INT);
                        System.out.print("Please enter the maximum allowable score:");
                        response = getIntOrExit();
              }while (!done);
         // The overall strategy to building up a student work object is
         // to have the student-bulding method call on the exam-building
         // method, which calls upon user input methods to get exam info.
         // Thus, user entered info is successively grouped together
         // into bigger units to build the entire student information set.
         // obtainOneStudentsWork() builds the five exams
         // and constructs the student work object from them
         private void obtainOneStudentsWork()
              // *** YOUR CODE GOES HERE ***
              int index = 1;
              Exam exam1 = buildOneExam(index);
              index = 2;
              Exam exam2 = buildOneExam(index);
              index = 3;
              Exam exam3 = buildOneExam(index);
              index = 4;
              Exam exam4 = buildOneExam(index);
              index = 5;
              Exam exam5 = buildOneExam(index);
              thisWork = new OneStudentsWork(exam1, exam2, exam3, exam4, exam5);
         // buildOneExam(thisTest) reads the exam information for one exam and returns an
         // Exam object constructed from this information. Uses obtainWasExamTaken() to
         // determine if the exam was taken and obtainOneScore() to get the exam score, if needed.
         private Exam buildOneExam(int thisTest)
              // *** YOUR CODE GOES HERE ***
              int score = 0;
              if(obtainWasExamTaken(thisTest))
                   score = obtainOneScore(thisTest);
              return new Exam(score);
              else
              return new Exam();
              System.out.println("Enter score for exam1:");
              Exam exam1 = new Exam(getIntOrExit());
              System.out.println("Enter score for exam2:");
              Exam exam2 = new Exam(getIntOrExit());
              System.out.println("Enter score for exam3:");
              Exam exam3 = new Exam(getIntOrExit());
              System.out.println("Enter score for exam4:");
              Exam exam4 = new Exam(getIntOrExit());
              System.out.println("Enter score for exam5:");
              Exam exam5 = new Exam(getIntOrExit());
         // obtainWasExamTaken(thisTest) keeps asking the user whether 'thisTest' was taken
         // (e.g., "Was exam 1 taken? Enter Y, N or Q", if thisTest equals 1)
         // until s/he provides a valid response. If Q is entered, we leave the
         // program immediately; if Y or N (yes or no), return true if yes, false if no
         private boolean obtainWasExamTaken(int thisTest)
              // *** YOUR CODE GOES HERE ***
              String response = INVALID_RESPONSE;
              System.out.println("Was Exam" + thisTest + "taken?");
              while (response.equals(INVALID_RESPONSE))
                   System.out.println("Please Enter" + " " + YES + " " + NO + " " + "or" + " " + EXIT_PROGRAM);
                   response = getYNOrExit();
              if (response.equals(YES))
              return true;
              else
              return false;
         // obtainOneScore(thisTest) keeps asking the user to enter a score for
         // 'thisTest' (e.g., "Enter the score for exam 1", is thisTest equals 1)
         // until s/he provides one within range or s/he tells us to exit the program.
         private int obtainOneScore(int thisTest)
              // *** YOUR CODE GOES HERE ***
              int response = INVALID_INT;
              if (response >= minAllowedScore && response <= maxAllowedScore);
                   System.out.println("Enter the Score for Exam" + thisTest + ":");
                   response = getIntOrExit();
              while (response > ABSOLUTE_MAX_SCORE || response < ABSOLUTE_MIN_SCORE)
                   System.out.println("INVALID: " + INVALID_INT);
                   System.out.println("Please Enter again:");
                   response = getIntOrExit();
              return response;
         // scoreIsWithinRange() returns true if the given score is inside of
         // the allowable range and false if it is out of range
         private boolean scoreIsWithinRange(int score)
              // *** YOUR CODE GOES HERE ***
              if (score >= minAllowedScore && score <= maxAllowedScore)
                   return true;
              else
                   return false;
         // getYNQ() reads a String from the console and returns it
         // if it is "Y" or "N" or exits the program if "Q" is entered;
         // the method returns INVALID_RESPONSE if the response is other
         // than"Y", "N" or "Q".
         // Do not modify this code!
         private String getYNOrExit()
              String usersInput = INVALID_RESPONSE;
              try
                   usersInput = console.readLine();
              catch (IOException e)
                   // never happens with the keyboard...
              usersInput = usersInput.toUpperCase();
              if (usersInput.equals(EXIT_PROGRAM))
                   System.out.println("Leaving...");
                   System.exit(0);
              if (usersInput.equals(YES) || usersInput.equals(NO))
                   return usersInput;
              else
                   return INVALID_RESPONSE;
         // getIntOrExit() reads an integer from the console and returns it.
         // If the user types in "Q", the program exits. If an integer is entered,
         // it is returned. If something that is not an integer (e.g. "Alex"), the
         // program returns INVALID_INT
         // Do not modify this code!
         private int getIntOrExit()
              String usersInput = "";
              int theInteger = 0;
              try
                   usersInput = console.readLine();
              catch (IOException e)
                   // never happens with the keyboard...
              // if the user wants to quit, bail out now!
              if(usersInput.toUpperCase().equals(EXIT_PROGRAM))
                   System.out.println("Program halting at your request.");
                   System.exit(0);
              // see if we have an integer
              try
                   theInteger = Integer.parseInt(usersInput);
              catch (NumberFormatException e)
                   // user's input was not an integer
                   return INVALID_INT;
              return theInteger;
         //                    -------------------- User output methods --------------------
         // printWelcomeMessage() prints a welcome message to the user explaining
         // what the program does and what it expects the user to do. In
         // particular, it needs to tell the user the absolute lowest and
         // highest acceptable exam scores
         private void printWelcomeMessage()
              // *** YOUR CODE GOES HERE ***
              System.out.println("Welcome!");
              System.out.println("This program computes the average, the variance, and the standard deviation of 5 exams");
              System.out.println("The lowest acceptable score is 0 and the highest is 1000");
         // printResults() prints all of the scores present, then prints the
         // statistics about them. The statistics that can have factional parts
         // -- average, variance and standard deviation -- should be printed with
         // exactly three digits after the decimal point. If a statistic could not be
         // computed, a message to that effect should print (NOT the "phony" value stored
         // in the statistic to tell the program that the statistic could not be computed).
         public void printResults()
              // These statements create a NumberFormat object, which is part
              // of the Java library. NumberFormat objects know how to take
              // doubles and turn them into Strings, formatted in a particular
              // way. First, you tell the NumberFormat object (nf) how you'd like
              // the doubles to be formatted (in this case, with exactly 3
              // digits after the decimal point). When printing a double you call
              // format to format it -- e.g. nf.format(the-number-to-format)
              NumberFormat nf = NumberFormat.getInstance();
              nf.setMinimumFractionDigits(3);
              nf.setMaximumFractionDigits(3);
              // *** YOUR CODE GOES HERE ***
              System.out.println("Score for Exam1 is:" + thisWork.getExam1().getScore());
              System.out.println("Score for Exam2 is:" + thisWork.getExam2().getScore());
              System.out.println("Score for Exam3 is:" + thisWork.getExam3().getScore());
              System.out.println("Score for Exam4 is:" + thisWork.getExam4().getScore());
              System.out.println("Score for Exam5 is:" + thisWork.getExam5().getScore());
              if (thisWork.getStatistics().getMinimum() == Statistics.CANT_COMPUTE_STATISTIC)
                   System.out.println("Can't compute the Minimum");
              else
                   System.out.println("the Minimum is:" + thisWork.getStatistics().getMinimum());
              if (thisWork.getStatistics().getMaximum() == Statistics.CANT_COMPUTE_STATISTIC)
                   System.out.println("Can't compute the Minimum");
              else
                   System.out.println("the Maximum is:" + thisWork.getStatistics().getMaximum());
              if (thisWork.getStatistics().getAverage() == Statistics.CANT_COMPUTE_STATISTIC)
                   System.out.println("Can't compute the Average");
              else
                   System.out.println("the Average is:" + thisWork.getStatistics().getAverage());
              if (thisWork.getStatistics().getVariance() == Statistics.CANT_COMPUTE_STATISTIC)
                   System.out.println("Can't compute the Variance");
              else
                   System.out.println("the Variance is:" + thisWork.getStatistics().getVariance());
              if (thisWork.getStatistics().getStandardDeviation() == Statistics.CANT_COMPUTE_STATISTIC)
                   System.out.println("Can't compute the Standard Deviation");
              else
                   System.out.println("the Standard Deviation is:" + thisWork.getStatistics().getStandardDeviation());
    // OneStudentsExams.java for Lab 2
    // ICS 21 Fall 2002
    // OneStudentsWork is the exams and the statistics computed from
    // them that comprise one student's work
    class OneStudentsWork
         public static final int NUMBER_OF_EXAMS = 5;
         // The student is offered five exams...
         private Exam exam1;
         private Exam exam2;
         private Exam exam3;
         private Exam exam4;
         private Exam exam5;
         // The statistics on those exams
         Statistics studentStats;
         //                    -------------------- Constructor --------------------
         // Takes five constructed exam objects and store them for this student.
         // Constructs a statistics object that holds the stats for these exams and
         // store it in studentStats.
         public OneStudentsWork(Exam test1, Exam test2, Exam test3, Exam test4, Exam test5)
              // *** YOUR CODE GOES HERE ***
              exam1 = test1;
              exam2 = test2;
              exam3 = test2;
              exam4 = test4;
              exam5 = test5;
              studentStats = new Statistics(test1, test2, test3, test4, test5);
         //                    -------------------- Accessor methods --------------------
         // getExamX() methods make available ExamX
         public Exam getExam1()
              return exam1;
         public Exam getExam2()
              return exam2;
         public Exam getExam3()
              return exam3;
         public Exam getExam4()
              return exam4;
         public Exam getExam5()
              return exam5;
         // getStatistics() makes available the Statistics object that is part of this student's work
         public Statistics getStatistics()
              return studentStats;
    // Statistics.java for Lab 2
    // ICS 21 Fall 2002
    // A Statistics object stores the statistics for a group of Exams.
    class Statistics
         // This constant denotes a statistic that cannot be
         // computed, such as an average of zero scores or a variance
         // of one score.
         public static final int CANT_COMPUTE_STATISTIC = -9999;
         // The stats
         private int minimum;
         private int maximum;
         private int numberOfExamsTaken;
         private double average;
         private double variance;
         private double standardDeviation;
         //                    -------------------- Constructor --------------------
         // Calculates (initializes) the statistics, using passed-in exams.
         // Note that the order of computing thst stats matters, as some
         // stats use others; for instance, variance must be computed before
         // standard deviation.
         public Statistics(Exam exam1, Exam exam2, Exam exam3, Exam exam4, Exam exam5)
              // *** YOUR CODE GOES HERE ***
              calculateAverage(exam1,exam2,exam3,exam4,exam5);
              calculateVariance(exam1,exam2,exam3,exam4,exam5);
              calculateStandardDeviation(exam1,exam2,exam3,exam4,exam5);
         //                    -------------------- Accessor methods --------------------
         // getNumberOfExamsTaken() makes available the number of exams this student undertook
         public int getNumberOfExamsTaken()
              return numberOfExamsTaken;
         // getMinimum() makes the minimum available
         public int getMinimum()
              return minimum;
         // getMaximum() makes the maximum available
         public int getMaximum()
              return maximum;
         // getAverage() makes the average available
         public double getAverage()
              return average;
         // getVariance() make the variance available
         public double getVariance()
              return variance;
         // getStandardDeviation() make the standard deviation available
         public double getStandardDeviation()
              return standardDeviation;
         //                    -------------------- Statistics methods --------------------
         //     ---> Note: all statistics are to be computed using the number of exams taken
         // calculateNumberOfExamsTaken() computes the number of tests the student took
         // and stores the result in 'numberOfExamsTaken'
         // (Note this statistic can always be computed.)
         private void calculateNumberOfExamsTaken(Exam exam1, Exam exam2, Exam exam3, Exam exam4, Exam exam5)
              // *** YOUR CODE GOES HERE ***
              numberOfExamsTaken = OneStudentsWork.NUMBER_OF_EXAMS;
         // calculateMinimum() sets 'minimum' to the minimum score of exams taken, or
         // to CANT_COMPUTE_STATISTIC if a minimum can't be computed.
         private void calculateMinimum(Exam exam1, Exam exam2, Exam exam3, Exam exam4, Exam exam5)
              // *** YOUR CODE GOES HERE ***
              /*min = exam1.getScore();
              if (min > exam2.getScore())
                   min = exam2.getScore();
              if (min > exam3.getScore())
                   min = exam3.getScore();
              if (min > exam4.getScore())
                   min = exam4.getScore();
              if (min > exam5.getScore())
                   min = exam5.getScore();
              if(numberOfExamsTaken == 0)
                   minimum = CANT_COMPUTE_STATISTIC;
              else if(numberOfExamsTaken == 1)
                   minimum = exam1.getScore();
              else
                   minimum = exam1.getScore();
                   if(numberOfExamsTaken >= 2 && numberOfExamsTaken <= minimum)
                        minimum = exam2.getScore();
                   if(numberOfExamsTaken >= 3 && numberOfExamsTaken <= minimum)
                        minimum = exam3.getScore();
                   if(numberOfExamsTaken >= 4 && numberOfExamsTaken <= minimum)
                        minimum = exam4.getScore();
                   if(numberOfExamsTaken >= 5 && numberOfExamsTaken <= minimum)
                        minimum = exam5.getScore();
              if (getMinimum() == ExamsManager.ABSOLUTE_MIN_SCORE)
                   minimum = exam1.getScore();
                   //exam1.getScore() = getMinimum();
              else
                   exam1.getScore() = CANT_COMPUTE_STATISTIC;
         // calculateMaximum() sets 'maximum' to the maximum score of exams taken, or
         // to CANT_COMPUTE_STATISTIC if a maximum can't be computed.
         private void calculateMaximum(Exam exam1, Exam exam2, Exam exam3, Exam exam4, Exam exam5)
              // *** YOUR CODE GOES HERE ***
              /*if (maximum == ExamsManager.ABSOLUTE_MAX_SCORE)
              return true;
              else
              return CANT_COMPUTE_STATISTIC;*/
              max = exam1.getScore();
              if (max < exam2.getScore())
                   max = exam2.getScore();
              if (max < exam3.getScore())
                   max = exam3.getScore();
              if (max < exam4.getScore())
                   max = exam4.getScore();
              if (max < exam5.getScore())
                   max = exam5.getScore();
              if(numberOfExamsTaken == 0)
                   maximum = CANT_COMPUTE_STATISTIC;
              else if(numberOfExamsTaken == 1)
                   maximum = exam1.getScore();
              else
                   maximum = exam1.getScore();
                   if(numberOfExamsTaken >= 2 && numberOfExamsTaken >= maximum)
                        maximum = exam2.getScore();
                   if(numberOfExamsTaken >= 3 && numberOfExamsTaken >= maximum)
                        maximum = exam3.getScore();
                   if(numberOfExamsTaken >= 4 && numberOfExamsTaken >= maximum)
                        maximum = exam4.getScore();
                   if(numberOfExamsTaken >= 5 && numberOfExamsTaken >= maximum)
                        maximum = exam5.getScore();
         // calculateAverage() computes the average of the scores for exams taken and
         // stores the result in 'average'. Set to CANT_COMPUTE_STATISTIC if there
         // are no tests taken.
         private void calculateAverage(Exam exam1, Exam exam2, Exam exam3, Exam exam4, Exam exam5)
              // *** YOUR CODE GOES HERE ***
              if (numberOfExamsTaken == 5)
                   average = (exam1.getScore()+exam2.getScore()+exam3.getScore()+exam4.getScore()+exam5.getScore()/OneStudentsWork.NUMBER_OF_EXAMS);
              else if (numberOfExamsTaken == 4)
                   average = (exam1.getScore()+exam2.getScore()+exam3.getScore()+exam4.getScore()/OneStudentsWork.NUMBER_OF_EXAMS);
              else if (numberOfExamsTaken == 3)
                   average = (exam1.getScore()+exam2.getScore()+exam3.getScore()/OneStudentsWork.NUMBER_OF_EXAMS);
              else if (numberOfExamsTaken == 2)
                   average = (exam1.getScore()+exam2.getScore()/OneStudentsWork.NUMBER_OF_EXAMS);
              else if (numberOfExamsTaken == 1)
                   average = (exam1.getScore()/OneStudentsWork.NUMBER_OF_EXAMS);
              else if (numberOfExamsTaken == 0)
                   average = CANT_COMPUTE_STATISTIC;
         // calculateVariance() calculates the returns the variance of the
         // scores for exams taken and stores it in 'variance'
         // For a small set of data (such as this one), the formula for calculating variance is
         // the sum of ((exam score - average) squared) for scores of exams taken
         // divided by (the number of scores - 1)
         // Set to CANT_COMPUTE_STATISTIC if there are fewer than two tests taken.
         private void calculateVariance(Exam exam1, Exam exam2, Exam exam3, Exam exam4, Exam exam5)
              // *** YOUR CODE GOES HERE ***
              if (numberOfExamsTaken == 5)
                   variance = ((exam1.getScore()-average)*(exam1.getScore()-average)+(exam2.getScore()-average)*(exam2.getScore()-average)+(exam3.getScore()-average)*(exam3.getScore()-average)+(exam4.getScore()-average)*(exam4.getScore()-average)+(exam5.getScore()-average)*(exam5.getScore()-average))/4;
              else if (numberOfExamsTaken == 4)
                   variance = ((exam1.getScore()-average)*(exam1.getScore()-average)+(exam2.getScore()-average)*(exam2.getScore()-average)+(exam3.getScore()-average)*(exam3.getScore()-average)+(exam4.getScore()-average)*(exam4.getScore()-average))/4;
              else if (numberOfExamsTaken == 3)
                   variance = ((exam1.getScore()-average)*(exam1.getScore()-average)+(exam2.getScore()-average)*(exam2.getScore()-average)+(exam3.getScore()-average)*(exam3.getScore()-average))/4;
              else if (numberOfExamsTaken == 2)
                   variance = ((exam1.getScore()-average)*(exam1.getScore()-average)+(exam2.getScore()-average)*(exam2.getScore()-average))/4;
              else if (numberOfExamsTaken < 2)
                   variance = CANT_COMPUTE_STATISTIC;
         // calculateStandardDeviation() calculates the standard
         // deviation of the scores of taken exams and stores
         // it in 'standardDeviation'
         // The formula for calculating standard deviation is just
         // the square root of the variance
         private void calculateStandardDeviation(Exam exam1, Exam exam2, Exam exam3, Exam exam4, Exam exam5)
              // *** YOUR CODE GOES HERE ***
              if (variance == CANT_COMPUTE_STATISTIC)
                   standardDeviation = CANT_COMPUTE_STATISTIC;
              else
                   standardDeviation = (Math.sqrt(variance));
    // Exam.java for Lab 2
    // ICS 21 Fall 2002
    // An Exam object stores information about one exam
    class Exam
         private boolean examTaken;     //was the exam taken? true for yes, false for no
         private int score;               //the exam's score; = 0 if test not taken
         //                    -------------------- Constructors --------------------
         // Construct a taken exam; it has score 's'
         public Exam(int s)
              score = s;
              examTaken = true;
         // Construct an exam not taken; it has a score of 0
         public Exam()
              score = 0;
              examTaken = false;
         //                    -------------------- Accessor methods --------------------
         // Make the score of an exam available
         public int getScore()
              return score;
         // Make available whether an exam was taken
         public boolean wasTaken()
              return examTaken;

    Your code is absolutely unreadable - even if someone was willing to
    help, it's simply impossible. I do give you a few tips, though: If you
    understand your code (i.e. if it really is YOUR code), you should be
    able to realize that your minimum and maximum never get set (thus they
    are both 0) and your exam 3 is set with the wrong value. SEE where
    those should get set and figure out why they're not. Chances are you
    are doing something to them that makes one 'if' fail or you just
    erroneously assign a wrong variable!

  • Information Retrieval with Genetic Programming using J2ME and Java WTK

    i have a big project to make a software using java programming especially n using J2ME and Java Wireless Toolkit, and i'm a begginer for java programming. I have no idea for the interface and how to setting connection between my phone mobile and GPRS. what should i do? thank you

    I believe MIT has lots of sourcecode. Try searching their site.

  • I have a program that requires Java...which won't open...says it can't detect it...I've uninstalled and re-installed but still the same problem.

    I have a program that requires Java, but when I go to launch the program...the Java sign just keeps searching, but my computer says
    that it can't detect Java..I have uninstalled and reinstalled Java, and its updates...any ideas? I can open this program at school, but not on my Imac.

    Without an product info, such as OS, this is just a guess:
    MadMAC0 posted at https://discussions.apple.com/message/20107182?ac_cid=tw123456#20107182 that:
    Apple has posted (10/22/12) the approved solution for restoring the Java 6 plug-in:
    Java for OS X 2012-006: How to re-enable the Apple-provided Java SE 6 applet plug-in and Web Start functionality.

  • Programming Cameras and Pan-Tilts with DirectX and Java

    Hi everybody!
    I am looking for the book and CD for the book "Programming Cameras and Pan-tilts with DirectX and Java", by Ioannis Pavlidis, Vassilios Morellas, Pete Roeber. Morgan Kaufmann 2003. It is out of print. I cannot find it anywhere.
    Does anyone have a copy of the CD-ROM and would be willing to sell it to me?
    Many thanks for your help and input!
    Cheers,
    WP

    can you share cd-rom?
    Or can you send me the url where I can find the cd-rom?
    agungws
    agung at gmail dot com

  • Desperately need Java network programming help!!!

    I need to make a Distributed File Sharing System (DFSS) using java language. The system should not make use of the central file server. The system should coordinate the concurrent access of files over the distributed environment. Caching may be used to enhance the system performance.
    It is basically network programming.
    Does any one have any idea how to make the DFSS. If you do please help!!!
    thank you in advance for you help
    cheers

    well, you're getting somewhere I guess. My original answer was intentionally vague because your original question was so vague. These fora are no good for asking questions like "how do I implement a distributed file system", they are good for asking things like "the following line(s) of code generate the following condition I didn't expect, rather I expected this condition, could someone tell me what is going on?" or something of similar specificity.
    So you are now asking how to, for instance, check to see if a text file is being shared. This is still too vague, but it's better than "how do I write a file sharing system". If you are feeling particularly industrious, go look at a project JXTA at http://www.jxta.org/ - it's open source, you can look at the code. Of course, if you're brand new, this might not help. In fact, not to discourage you, but if you're that new, this is not the project to be doing.
    Good Luck
    Lee

  • JRE 6 freeze browsers and Java Control Panel Applet stops working!

    Hello,
    this is the second time I got this problem with Java JRE 6 ! First one was a month or two ago:
    I have Java JRE 6 update 20 installed on a Windows 7 64bit ultimate. It was working...much time ago...then i found my browser (firefox, google chrome or IE8) was freezing when I open java application or test pages. I tried uninstalling it, cleaning the system with Revo Uninstaller, or CCleaner or JavaRA and reinstalling with no luck. The other problem is the same that user Mass8 had (http://forums.sun.com/thread.jspa?threadID=5372196&start=15&tstart=0)
    ...my java control panel applet is not working and give me this:
    http://www.iouppo.com/lite/pics/df9b61008b5bf9de61a13d8bfa3ddad1.jpg
    I tried disabling UAC, running JRE, starting Win7 in safe mode with network...but browser always freeze. It's not a true freeze, with CPU busy at 100% (cpu stays in idle) but it seems to wait for something. It's not a problem with video card driver on my machine, because I can start java control panel from command prompt...and without the noddraw switch, using this command:
    javaw -Xbootclasspath/a:..\lib\deploy.jar -Duser.home="%HOMEDRIVE%%HOMEPATH%" com.sun.deploy.panel.ControlPanel
    This was the description of my first time.....then I replaced my system with an Acronis image...and I used the system for sometimes....and Java was working until 3-4 days ago! So I did another image of the system with all things working.
    Then this morning...I tried the java test page.....and surprise! It's not working anymore!
    In these days I think I only disabled UAC and Account virtualization....maybe JAVA saves things there...and then when I disabled UAC (Windows7 deleted those folders and files) it can't find there anymore???? Who can help me?
    I don't want to restore my image every month!
    My system is 100% virus free and from the last image restoration I didn't visit suspicious sites and so on....I have antivirus and antispyware software...all is perfectly CLEAN. Any ideas or things to try?

    I'm beginning to think it's something related to Hybernation after using JAVA....I'm using it very often...and if I use it...and I suspect Java is KO...i try control panel and it doesn't works....then I try with browser and it freeze (or keep waiting...and i can only force to close it)
    THEN,
    when I reboot my system I get this window
    http://www.iouppo.com/lite/pics/09501eb799c165bb25ece8fd3261e41c.jpg
    suggesting me to rename the folder C:\Program in C:\Program1 ...and if i don't rename it...java will never work...instead if I allow it...Windows will fix it!......This until...the next hybernation....:(....
    try to replicate this...maybe I found where is the problem..

  • Network Programming exam papers (college exam papers)

    hello.
    my name is james mcfadden and i am a final year (4th year) undergraduate computing student at Letterkenny Institute of Technology. my e-mail address is [email protected] I have a question here for you. Would you have links to online versions of final year undergraduate Computing exam papers, specifically Networked Applications Development and or Network Management exam papers? I was only able to get access to Trinity College Dublin�s exam papers and Letterkenny IT�s exam papers.
    The 2005/06 academic year is the 1st academic year that final year undergraduate computing students at Letterkenny IT are being taught how to continue doing network programming in Java. i was taught how to do simple network programs in Java when I was in 3rd year.
    The name of the network programming subject that I�m doing in 4th year is Network Programming for Broadband Systems. It is divided into 2 parts: Programming and Networks. In past exam papers (C++ papers), a student would have had to answer 4 out of 6 questions. There would�ve been 4 programming questions and 2 networking questions on those papers. It is going to be the same for both the Summer and Autumn 2007 Broadband Network Programming exam papers, apart from fact that they will be Java papers and that a lot of the material that I have learned is new.
    In 4th year I did Multicast Sockets, Threads, Non-Blocking I/O, Remote Method Invocation, Protocol Handlers, and Content Handlers for the Programming part of the subject (Java Network Programming, 3rd Edition, by Elliote Rusty Harold).
    I did Network Security and Network Management for the Networks part of the subject (Computer Networking : A Top-Down Approach Featuring The Internet, 3rd Edition, by James F. Kurose and Keith W. Ross).
    Your help is greatly appreciated.
    Thank you.

    I have a question here for you.
    Would you have links to online versions of final year
    undergraduate Computing exam papers, specifically
    Networked Applications Development and or Network
    Management exam papers? No

Maybe you are looking for

  • Need video connection with daughter in Europe

    My daughter is off for a college Semester Abroad - would love to talk and see each other with iChat - I have a wonderful Mac, she's stuck with her PC labtop. Any suggestions for us? I read the threads, ideas include iChat and/or Skype?? Not very comp

  • Downloading iPhoto after deleting it! oops, help!

    I deleted my iPhoto cuz it was giving me trouble and I couldn't fix it. Now that I'm trying to find it on the apple web site to re-down load it I'm coming up with all these problems, first one was with the iPhoto 5 it wont up load cuz there is no tra

  • Edit with errors

    I'm trying to "edit with" (i.e. right click on an image link, select edit with> photoshop CS4) images with Indesign CS4 and Photoshop CS4. Wierdly my system opens powerpoint and tries to edit with powerpoint instead (it fails obviosuly) Any idea what

  • Regarding an exception

    While doing delete operation I am getting exception in testing instance and i am not able to see the error. If I am enabling the diagnostics option then the error is not coming and code is working fine. I am providing the controller code and metod to

  • PS CS6  - text and font changes by clicking on it - not reversible

    Sometimes I open a file with layers in PS and click on a text layer, to move or change it, and immediately the text and font changes into another text/font from the document. Can not save the file then the problem stays forever. I can´t touch/change