Need help with simple stuff not compiling

I just started to use java today and I don't understand things very well...
I am working on doing arithmetic in java and when attempting to compile my program I get a list of 5 errors saying
"Arithmetic.java:17: package system does not exist
system.out.println(The sum is: "+ sum);
Arithmetic.java:22: package system does not exist
system.out.println(The difference is: "+ difference);"
and so on... in my Command Shell...
Here is the original code...
Arithmetic Java
This program demonstrates the arithmetic operators available in Java
public class Arithmetic {
public static void main(String[] args) {
int numberA = 10;
int numberB = 7;
//Addition+
int sum = numberA + numberB;
system.out.println("The sum is: "+ sum);
//Subtraction-
int difference = numberA - numberB;
difference = numberB - numberA;
system.out.println("The difference is: "+ difference);
//Multiplication*
int product= numberA * numberB;
system.out.println("The product is: "+ product);
//Division/
int quotient= numberA / numberB;
system.out.println("The quotient is: "+ quotient);
double doubleQuotient = (double) numberA / numberB;
system.out.println("the doubleQuotient is: " + doubleQuotient);
//Modulus%
int remainder = numberA % numberB;
System.out.println("the remainder is: " + remainder);
int CrazyEquasion = 4 + 7 *10 -11 *12;
System.out.println("The CrazyEquasion is: " + CrazyEquasion);
//Inc
//numberA = numberA + 1;
//numberA++;
//++numberA;
int increment = ++numberA;
System.out.println("The increment is: " + increment);
//Dec
numberA = numberA - 1;
numberA--;
--numberA;
numberA = numberA + numberB;
numberA += numberB;
numberA = numberA - numberB;
numberA -= numberB;
an explanation of what it means by packages is what I really am hoping for in the answer     
Any help would be appreciated...
though I doubt this is worth anyone's time
Edited by: Prokaryote on Jul 21, 2008 4:35 AM

system.out.println();
or
System.out.println();

Similar Messages

  • Need Help With Simple ABAP Code

    Hello,
    I'm loading data from a DSO (ZDTBMAJ) to an Infocube (ZCBRAD06). I need help with ABAP code to some of the logic in Start Routine. DSO has 2 fields: ZOCTDLINX & ZOCBRDMAJ.
    1. Need to populate ZOCPRODCD & ZOCREFNUM fields in Infocube:
        Logic:-
        Lookup /BI0/PMATERIAL, if /BIC/ZOCBRDMAJ = /BIC/OIZOCBRDMAJ
        then /BIC/ZOCPRODCD = ZOCPRODCD in Infocube
               /BIC/ZOCREFNUM = ZOCREFNUM in Infocube         
    2. Need to populate 0G_CWWTER field in Infocube:
        Logic:
        Lookup /BIC/PZOCTDLINX, if /BIC/ZOCTDLINX = BIC/OIZOCTDLINX
        then G_CWWTER = 0G_CWWTER in Infocube.
    I would need to read single row at a time.
    Thanks!

    I resolved it.

  • Need help with simple XML validation

    I am new to Spry and need some help creating a simple
    validation. There is a form field which must not contain a value
    already in the database. I have a script which accepts a parameter
    and returns a boolean result. Here is the XML:
    <samples>
    <sample>
    <ISFOUND>0</ISFOUND>
    </sample>
    </samples>
    1. How do I call this script when the form field changes and
    pass the form value as the parameter?
    2. How do I check the returned value in the XML and throw an
    error if true?
    I appreciate any help with this. Please let me know if there
    is a better way to achieve the same result.
    Thanks,
    Rich

    I enabled the call to the XML response. However, I am having
    trouble identifying when the call is complete so I can parse the
    result. How do I run my check after the data load and display the
    proper message?

  • I need help with simple problems. im a student.

    i'd like to be advanced with my studies so i will post questions.. i need help on how to answer. thank you.
    1. create a java program that will evaluate if the value entered is a positive, negative, vowel, consonant and special characters.
    im actually done with the positive and negative using if else statements.. i used an integer data type. now my question is how do conjoin the characters when i need to evaluate a vowel and a consonant. i cant use char either. please help. i dont know what to do yet.
    2. create java program that will translate the input from numbers to words. e.g. input:123 output: one hundred twenty-three.
    i have an idea to use a switch case statement. but i have no idea on how will i be able to do it. so if you guys can help me.. well then thankies..

    Welcome to the Sun forums. First, please note that you have posted in the wrong forum. This forum is for topics related to Sun's JavaHelp product. You should post your questions in the New to Java forum.
    As part of your learning, you will have to develop the ability to select an approach to a problem, create a design that reflects that approach, and then implement the design with code that you create.
    So, it's inappropriate for us to take the problem statement that you have been given and short-circuit your learning process by giving you the implemented problem solution. We can comment on the individual questions that you may have, and point out problems and errors that we see in the code that you develop.
    As a hint, when you are stuck, forget about Java and programming. Just start with a sheet of paper and a pencil, and figure out how to layout the task on paper. The consider how to translate that to programming.
    If you have problems, post short example code that shows the problem, and explain your question clearly. We can't read minds.
    Make sure you post code correctly so that it's not mangled by the forum software, and so that formatting is maintained. Select your typed or pasted code block and press the CODE button above the typing area.

  • Beginner needs help with simple code.

    I just statrted learnind java, and I need some help with this simple program. For some reason everytime I enter my Farenheit value, the Celsius conversion returns as 0.0. Would really appreciate the help. Thanks.
    Here's the code:
    public class TempConverter
    public static void main(String[] args)
    double F = Double.parseDouble(args[0]);
    System.out.println("Temperature in Farenheit is: " + F);
    double C = 5 / 9;
    C *= (F - 32);
    System.out.println("Temperature in Celsius is: " + C);
    }

    double C = 5 / 9This considers "5" and "9" to be integers and does an integer division, discarding the remainder. The result of that division is 0. Trydouble C = 5.0/9.0;

  • Need Help with simple array program!

    Hi, I have just recently started how to use arrays[] in Java and I'm a bit confused and need help designing a program.
    What this program does, it reads in a range of letters specified by the user. The user then enters the letters (a, b or c) and stores these characters into an array, which the array's length is equal to the input range the user would enter at the start of the program. The program is then meant to find how many times (a,b and c) appears in the array and the Index it first appears at, then prints these results.
    Here is my Code for the program, hopefully this would make sense of what my program is suppose to do.
    import B102.*;
    class Letters
         static int GetSize()
              int size = 0;
              boolean err = true;
              while(err == true)
                   Screen.out.println("How Many Letters would you like to read in?");
                   size = Keybd.in.readInt();
                   err = Keybd.in.fail();
                   Keybd.in.clearError();
                   if(size <= 0)
                        err = true;
                        Screen.out.println("Invalid Input");
              return(size);
         static char[] ReadInput(int size)
              char input;
              char[] letter = new char[size];
              for(int start = 1; start <= size; start++)
                   System.out.println("Please enter a letter (a, b or c) ("+size+" max), enter # to stop:");
                   input = Keybd.in.readChar();
                   while((input != 'a') && (input != 'b') && (input != 'c') && (input != '#'))
                        Screen.out.println("Invalid Input");
                        System.out.println("Please enter a letter (a, b or c) ("+size+" max, enter # to stop:");
                        input = Keybd.in.readChar();
                                    while(input == '#')
                                                 start == size;
                                                 break;
                   for(int i = 0; i < letter.length; i++)
                        letter[i] = input;
              return(letter);
         static int CountA(char[] letter)
              int acount = 0;
              for(int i = 0; i < letter.length; i++)
                   if(letter[i] == 'a')
                        acount++;
              return(acount);
         static int CountB(char[] letter)
              int bcount = 0;
              for(int i = 0; i < letter.length; i++)
                   if(letter[i] == 'b')
                        bcount++;
              return(bcount);
         static int CountC(char[] letter)
              int ccount = 0;
              for(int i = 0; i < letter.length; i++)
                   if(letter[i] == 'c')
                        ccount++;
              return(ccount);
         static int SearchA(char[] letter)
              int ia;
              for(ia = 0; ia < letter.length; ia++)
                   if(letter[ia] == 'a')
                        return(ia);
              return(ia);
         static int SearchB(char[] letter)
              int ib;
              for(ib = 0; ib < letter.length; ib++)
                   if(letter[ib] == 'b')
                        return(ib);
              return(ib);
         static int SearchC(char[] letter)
              int ic;
              for(ic = 0; ic < letter.length; ic++)
                   if(letter[ic] == 'c')
                        return(ic);
              return(ic);
         static void PrintResult(char[] letter, int acount, int bcount, int ccount, int ia, int ib, int ic)
              if(ia <= 1)
                   System.out.println("There are "+acount+" a's found, first appearing at index "+ia);
              else
                   System.out.println("There are no a's found");
              if(ib <= 1)
                   System.out.println("There are "+bcount+" b's found, first appearing at index "+ib);
              else
                   System.out.println("There are no b's found");
              if(ic <= 1)
                   System.out.println("There are "+ccount+" c's found, first appearing at index "+ic);
              else
                   System.out.println("There are no c's found");
              return;
         public static void main(String args[])
              int size;
              char[] letter;
              int acount;
              int bcount;
              int ccount;
              int ia;
              int ib;
              int ic;
              size = GetSize();
              letter = ReadInput(size);
              acount = CountA(letter);
              bcount = CountB(letter);
              ccount = CountC(letter);
              ia = SearchA(letter);
              ib = SearchB(letter);
              ic = SearchC(letter);
              PrintResult(letter, acount, bcount, ccount, ia, ib, ic);
              return;
    }     Some errors i get with my program are:
    When reading in the letters to store into the array, I get the last letter I entered placed into the entire array. Also I believe my code to find the Index is incorrect.
    Example Testing: How many letters would you like to read? 3
    Enter letter (a, b or c) (# to quit): a
    Enter letter (a, b or c) (# to quit): b
    Enter letter (a, b or c) (# to quit): c
    It prints "There are no a's'" (there should be 1 a at index 0)
    "There are no b's" (there should be 1 b at index 1)
    and "There are 3 c's, first appearing at index 0" ( there should be 1 c at index 2)
    The last thing is that my code for when the user enters "#" that the input of letters would stop and the program would then continue over to the counting and searching part for the letters, my I believe is correct but I get the same problem as stated above where the program takes the character "#" and stores it into the entire array.
    Example Testing:How many letters would you like to read? 3
    Enter letter (a, b or c) (# to quit): a
    Enter letter (a, b or c) (# to quit): #
    It prints "There are no a's'" (should have been 1 a at index 0)
    "There are no b's"
    and "There are no c's"
    Can someone please help me??? or does anyone have a program simular to this they have done and would'nt mind showing me how it works?
    Thanks
    lou87.

    Without thinking too much...something like this
    for(int start = 0; start < size; start++) {
                System.out.println("Please enter a letter (a, b or c) ("+size+" max), enter # to stop:");
                input = Keybd.in.readChar();
                while((input != 'a') && (input != 'b') && (input != 'c') && (input != '#')) {
                    Screen.out.println("Invalid Input");
                    System.out.println("Please enter a letter (a, b or c) ("+size+" max, enter # to stop:");
                    input = Keybd.in.readChar();
                if(input == '#') {
                        break;
                letter[start] = input;
            }you dont even need to do start = size; coz with the break you go out of the for loop.

  • I REALLY need help with this! (not too hard) (but hard to explain) (long)

    I know that this isn't hard, but I just can't figure it out.
    I am trying to create artificial cellular life, but the cells will be able to go through sexual reproduction.
    The DNA for the cells is a 500 index boolean array. One array for Dominant genes, and another one for Rececive genes.
    The DNA is generated randomly.
    The division (to make a sperm cell) works like this -
    1. I get a random number with the Math.random() function, and I use the Math.round() function to round it to either a 1, or a 0.
    2. The boolean arrays are converted to integer arrays (true = 1, false = 0).
    3. If the random number is a 1, then (in a for loop) the current index value of the dominant array is changed to a 3. If the random numnber is equal to a 0, then the current index value of the rececive array is changed to a 3.
    I started working on a new class, to combine the sperm cell with another sperm cell (call it an egg cell, whatever, doesn't matter) in order to create a new complete cell.
    I realized that I have no idea how I can reuse my classes, and make NEW cells, without overwriting my old cells.
    All of the final information that the classes produce is passed through TestMain.class (which puts it into other variables, and sends it to the appropriate class).
    So, I need to be able to run the process for creating a cell, then creating a sperm cell out of it, twice.
    I can, of course, just copy and paste this action, but seeing as how I want to have unlimited amounts of cells in action, this would not be practical.
    Here are my classes, sorry that they are not commented, but I explained what they do above, and I will write what they do overall.
    Genes.java - Creates the random DNA (and is essentially the cell)
    public class Genes {
    public boolean[] domgenes = new boolean[501];
    public boolean[] recgenes = new boolean[501];
        public void randgenes()
    System.out.println ("Dominant Genome: ");
    System.out.println ("");
    int domcount = 0;
            for(int i=0; i<500; i++) {
                double tempgene = (Math.round((Math.random())));
                int tempdomgene = (int)(tempgene);
                  if(tempdomgene == 1) {
                  domgenes[i] = true;
                System.out.print(1);
                  else {
                  domgenes[i] = false;
                System.out.print(0);
              for (int x = 0; x<500; x++) {
                if (domcount == 0) {
                System.out.println("");
                System.out.println("");
                System.out.println ("Rececive Genome: ");
                System.out.println("");
                domcount = 1;
                double tempgene = (Math.round((Math.random())));
                int temprecgene = (int)(tempgene);
                  if(temprecgene == 1) {
                  recgenes[x] = true;
                  System.out.print(1);
                  else {
                  recgenes[x] = false;
                  System.out.print(0);
        public boolean[] getdomGenes()
            System.out.println("");
            return domgenes; //returns the dominant genome
        public boolean[] getrecGenes()
            return recgenes; //returns the rececive geneome
        }DivideGenes.java - This creates the sperm cell out of the information that TestMain.java sent it (which is the information that Genes.java sent to it).
    public class DivideGenes
        int badcopy =0;
        boolean[] domgenes;
        boolean[] recgenes;
        int[] tempdomgenes = new int[501];
        int[] temprecgenes = new int[501];
        int tempgene;
        int geneholder;
        public DivideGenes(boolean[] domgenes, boolean[] recgenes)
            this.domgenes = domgenes;
            this.recgenes = recgenes;
       public int randommath() { //finds a random number
                double tempgene2 = Math.random();
                tempgene2 = tempgene2*500;
                tempgene = (int)tempgene2;
          return tempgene;
        public void randdivide() //main process
    for (int i = 0; i < 500; i++) {
    if (domgenes[i] == true) {
    tempdomgenes[i] = 1;
    else {
    tempdomgenes[i] = 0;
    if (recgenes[i] == true) {
    temprecgenes[i] = 1;
    else {
    temprecgenes[i] = 0;
            for (int i = 0; i < 500; i++) { //creates the sperm cell
    if (binmath() == 1) {
    tempdomgenes[i] = 3;
    else {
    temprecgenes[i] = 3;
      public int[] getNewDomGenes()
      return tempdomgenes;
      public int[] getNewRecGenes()
      return temprecgenes;
        public int binmath() {
        double tempbingene = (Math.round((Math.random())));
               int bingene = (int)(tempbingene);
                return bingene;
      }TestMain.java - This is the class that all of the result information is passed through, and is the regulator class (this is the class with the 'main' block). I used the names of the objects randomly, they do not represent anything (like cell2 does not represent the second cell), they are just names.
    public class TestMain
        public static void main(String[] args)
            Genes cell = new Genes();
            cell.randgenes();
            boolean[] theDominantGenes = cell.getdomGenes();
            boolean[] theRececiveGenes = cell.getrecGenes();
            DivideGenes cell2 = new DivideGenes(theDominantGenes, theRececiveGenes);
            cell2.randdivide();
           int[] theTempDominantGenes = cell2.getNewDomGenes();
           int[] theTempRececiveGenes = cell2.getNewRecGenes();
         CreateNewCell cell3 = new CreateNewCell (theTempDominantGenes,theTempRececiveGenes);
      cell3.CompileCell();
      }CreateNewCells.java - This is going to combine two sperm cells in order to make one new cell. It doesn't have anything in it so far, just some System.out.println stuff I made to show my friends.
    public class CreateNewCell {
    int[] tempdomgenes;
    int[] temprecgenes;
    public CreateNewCell(int[] tempdomgenes, int[] temprecgenes)
            this.tempdomgenes = tempdomgenes;
            this.temprecgenes = temprecgenes;
    public void CompileCell() {
    System.out.println("");
    System.out.println("Sperm Division Started");
    System.out.println("------------------------------------------");
    System.out.println("");
    System.out.println ("Dominant Genome after random gene elimination");
    System.out.println("");
    for (int i = 0; i < 500; i++) {
    System.out.print(tempdomgenes);
    System.out.println("");
    System.out.println("");
    System.out.println ("Rececive Genome after random gene elimination");
    System.out.println("");
    for (int i = 0; i < 500; i++) {
    System.out.print(temprecgenes[i]);
    Thank you very much if you choose to help me out.

    As I said before, your code is not object.
    When you write
    DivideGenes cell2 = new DivideGenes(theDominantGenes, theRececiveGenes);it means than from 2 Genes, you are creating a new object which is DivideGenes. I assume that what you want is to create a cell from an other cell and its mate.
    So it should be:
    public class Cell {
      //put here your gene class attributes and methods
      public Cell divideCell(Cell mate) {
         Cell child = new Cell();
         //put here your divide code
         return child;
    }Otherwise I can't understand your code.
    What kind of object is a createcellGene?? It must be a method of Cell !!
    ...

  • Need help with simple file sharing application

    I have an assignment to build a Java File Sharing application. Since I'm relatively new to programming, this is not gonna be an easy task for me.
    Therefore I was wondering if there are people willing to help me in the next few days. I will ask questions in this thread, there will be loads of them.
    I already have something done but I'm not nearly halfway finished.
    Is there a code example of a simple file sharing application somewhere? I didn't manage to find it.
    More-less, this is what it needs to contain:
    -client/server communication (almost over)
    -file sending (upload, download)
    -file search function (almost over)
    -GUI of an application.
    GUI is something I will do at the end, hopefully.
    I hope someone will help me. Cheers
    One more thing, I'm not asking for anyone to do my homework. I will only be needing some help in the various steps of building an application.
    As I said code examples are most welcome.
    This is what I have done so far
    Server:
    package ToJeTo;
    import java.io.*;
    import java.net.*;
    public class MultiServer {
        public static ServerSocket serverskiSoket;
        public static int PORT = 1233;
        public static void main(String[] args) throws IOException {
            try {
                serverskiSoket = new ServerSocket(PORT);
            }catch (IOException e) {
                System.out.println("Connection impossible");
                System.exit(1);
            do {
                Socket client = serverskiSoket.accept();
                System.out.println("accepted");
                ClientHandler handler = new ClientHandler(client);
                handler.start();
            } while(true);
    }Client:
    package ToJeTo;
    import java.io.IOException;
    import java.io.PrintWriter;
    import java.net.*;
    import java.util.Scanner;
    public class MultiClient {
        public static InetAddress host;
        public static int PORT = 1233;
        public static void main(String[] args) {
            try {
                host = InetAddress.getLocalHost();
            }catch (UnknownHostException uhe) {
                System.out.println("Error!");
                System.exit(1);
            sendMessages();
        private static void sendMessages() {
            Socket soket = null;
            try {
                soket = new Socket(host, PORT);
                Scanner networkInput = new Scanner(soket.getInputStream());
                PrintWriter networkOutput = new PrintWriter(soket.getOutputStream(), true);
                Scanner unos = new Scanner(System.in);
                String message, response;
                do {
                    System.out.println("Enter message");
                    message = unos.nextLine();
                    networkOutput.println(message);
                    response = networkInput.nextLine();
                    System.out.println("Server: " + response);
                }while (!message.equals("QUIT"));
            } catch (IOException e) {
                e.printStackTrace();
            finally {
                try{
                    System.out.println("Closing..");
                    soket.close();
                } catch (IOException e) {
                    System.out.println("Impossible to disconnect!");
                    System.exit(1);
    }ClientHandler:
    package ToJeTo;
    import java.io.*;
    import java.net.*;
    import java.util.*;
    public class ClientHandler extends Thread {
        private Socket client;
        private Scanner input;
        private PrintWriter output;
        public ClientHandler(Socket serverskiSoket) {
            client = serverskiSoket;
            try {
            input = new Scanner(client.getInputStream());
            output = new PrintWriter(client.getOutputStream(), true);
            } catch (IOException e) {
                e.printStackTrace();
            public void run() {
                String received;
                do {
                received = input.nextLine();
                output.println("Reply: " + received);
                } while (!received.equals("QUIT"));
                try {
                    if (client != null)
                        System.out.println("Closing the connection...");
                        client.close();
                }catch (IOException e) {
                    System.out.println("Error!");
    }Those three classes are simple client server multi-threaded connection.

    Now the other part that contains the search function looks like this:
    package ToJeTo;
    import java.io.*;
    import java.util.*;
    public class User {
        String nickname;
        String ipAddress;
        static ArrayList<String> listOfFiles = new ArrayList<String>();
        File sharedFolder;
        String fileLocation;
        public User(String nickname, String ipAddress, String fileLocation) {
            this.nickname = nickname.toLowerCase();
            this.ipAddress = ipAddress;
            sharedFolder = new File(fileLocation);
            File[] files = sharedFolder.listFiles();
            for (int i = 0; i < files.length; i++) {
                listOfFiles.add(i, files.toString().substring(fileLocation.length()+1));
    public static void showTheList() {
    for (int i = 0; i < listOfFiles.size(); i++) {
    System.out.println(listOfFiles.get(i).toString());
    @Override
    public String toString() {
    return nickname + " " + ipAddress;
    User Manager:
    package ToJeTo;
    import java.io.*;
    import java.util.*;
    class UserManager {
        static ArrayList<User> allTheUsers = new ArrayList<User>();;
        public static void addUser(User newUser) {
            allTheUsers.add(newUser);
        public static void showAndStoreTheListOfUsers() throws FileNotFoundException, IOException {
            BufferedWriter out = new BufferedWriter(new FileWriter("List Of Users.txt"));
            for (int i = 0; i < allTheUsers.size(); i++) {
                    System.out.println(allTheUsers.get(i));
                    out.write(allTheUsers.get(i).toString());
                    out.newLine();
            out.close();
    }Request For File
    package ToJeTo;
    import java.util.*;
    public class RequestForFile {
        static ArrayList<String> listOfUsersWithFile = new ArrayList<String>();
        Scanner input;
        String fileName;
        public RequestForFile() {
            System.out.println("Type the wanted filename here: ");
            input = new Scanner(System.in);
            fileName = input.nextLine();
            for (User u : UserManager.allTheUsers) {
                for (String str : User.listOfFiles) {
                    if (str.equalsIgnoreCase(fileName))
                        listOfUsersWithFile.add(u.nickname);
        public RequestForFile(String fileName) {
            for (User u : UserManager.allTheUsers) {
                for (String str : User.listOfFiles) {
                    if (str.equalsIgnoreCase(fileName))
                        listOfUsersWithFile.add(u.nickname);
        public static List<String> getAll() {
            for (int i = 0; i < listOfUsersWithFile.size(); i++) {
                //System.out.println("User that has the file: " + listOfUsersWithFile.get(i));
            return listOfUsersWithFile;
    }Now this is the general idea.
    The user logs in with his nickname and ip address. He defines his own shared folder and makes it available for other users that log on to server.
    Now each user has their own list of files from a shared folder. It's an ArrayList.
    User manager class is there to store another list, a list of users that are connected with server.
    When the user is searching for a particular file, he is searching through all the users and their respective files lists. Therefore for each loop inside a for each loop.
    Now the problem is how to connect all that with Client and Server class and put it into one piece.
    GUI should look somewhat like this:

  • Need Help with Simple Chat Program

    Hello Guys,
    I'm fairly new to Java and I have a quick question regarding a simple chat program in java. My problem is that I have a simple chat program that runs from its own JFrame etc. Most of you are probably familiar with the code below, i got it from one of my java books. In any case, what I'm attempting to do is integrate this chat pane into a gui that i have created. I attempted to call an instace of the Client class from my gui program so that I can use the textfield and textarea contained in my app, but it will not allow me to do it. Would I need to integrate this code into the code for my Gui class. I have a simple program that contains chat and a game. The code for the Client is listed below.
    import java.awt.*;
    import java.awt.event.*;
    import java.io.*;
    import java.net.*;
    import javax.swing.*;
    public class Client
    extends JPanel {
    public static void main(String[] args) throws IOException {
    String name = args[0];
    String host = args[1];
    int port = Integer.parseInt(args[2]);
    final Socket s = new Socket(host, port);
    final Client c = new Client(name, s);
    JFrame f = new JFrame("Client : " + name);
    f.addWindowListener(new WindowAdapter() {
    public void windowClosing(WindowEvent we) {
    c.shutDown();
    System.exit(0);
    f.setSize(300, 300);
    f.setLocation(100, 100);
    f.setContentPane(c);
    f.setVisible(true);
    private String mName;
    private JTextArea mOutputArea;
    private JTextField mInputField;
    private PrintWriter mOut;
    public Client(final String name, Socket s)
    throws IOException {
    mName = name;
    createUI();
    wireNetwork(s);
    wireEvents();
    public void shutDown() {
    mOut.println("");
    mOut.close();
    protected void createUI() {
    setLayout(new BorderLayout());
    mOutputArea = new JTextArea();
    mOutputArea.setLineWrap(true);
    mOutputArea.setEditable(false);
    add(new JScrollPane(mOutputArea), BorderLayout.CENTER);
    mInputField = new JTextField(20);
    JPanel controls = new JPanel();
    controls.add(mInputField);
    add(controls, BorderLayout.SOUTH);
    mInputField.requestFocus();
    protected void wireNetwork(Socket s) throws IOException {
    mOut = new PrintWriter(s.getOutputStream(), true);
    final String eol = System.getProperty("line.separator");
    new Listener(s.getInputStream()) {
    public void processLine(String line) {
    mOutputArea.append(line + eol);
    mOutputArea.setCaretPosition(
    mOutputArea.getDocument().getLength());
    protected void wireEvents() {
    mInputField.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent ae) {
    String line = mInputField.getText();
    if (line.length() == 0) return;
    mOut.println(mName + " : " + line);
    mInputField.setText("");

    Thanks for ur help!i have moved BufferedReader outside the loop. I dont think i am getting exception as i can c the output once.What i am trying to do is repeat the process which i m getting once.What my method does is first one sends the packet to multicasting group (UDP) and other method receives the packets and prints.

  • Need help with Mac & PC not recognizing external drive (disk not readable)

    I am having trouble getting my computer(s) to recognize my Seagate External Drive.
    Have tried on my MacBook, iMac, 2 Mini's & my roommate's PC and all reveal the same issue: The Disk you inserted was not readable by this computer.
    MacBook/iMac both are working off of Leopard
    Both Mini's are on Tiger
    It won't show up in finder, rendering it unobtainable. I need to get the information if at all possible off of this hard drive (very important!!) so any help I can get would be greatly appreciated!
    It allows me to go into disk utility where it shows up with this information:
    Name : ST316002 3A Media
    Type : Disk
    Partition Map Scheme : Master Boot Record
    Disk Identifier : disk4
    Media Name : ST316002 3A Media
    Media Type : Generic
    Connection Bus : USB
    USB Serial Number : 3LJ07T540000
    Device Tree : /PCI0@0/USB7@1D,7/@4:0
    Writable : Yes
    Ejectable : Yes
    Mac OS 9 Drivers Installed : No
    Location : External
    Total Capacity : 149.1 GB (160,041,885,696 Bytes)
    S.M.A.R.T. Status : Not Supported
    Disk Number : 4
    Partition Number : 0
    And it is in the "about this mac" section with this information:
    Seagate Mass Storage:
    Capacity: 149.05 GB
    Removable Media: Yes
    Detachable Drive: Yes
    BSD Name: disk4
    Version: 0.00
    Bus Power (mA): 500
    Speed: Up to 480 Mb/sec
    Manufacturer: Seagate
    Mac OS 9 Drivers: No
    Partition Map Type: MBR (Master Boot Record)
    Product ID: 0x0500
    Serial Number: 3LJ07T540000
    S.M.A.R.T. status: Not Supported
    Vendor ID: 0x0bc2

    Additional info:
    on the disk4s1 info in disk utility, this information is seen:
    Name : disk4s1
    Type : Volume
    Disk Identifier : disk4s1
    Mount Point : Not mounted
    Connection Bus : USB
    Device Tree : /PCI0@0/USB7@1D,7/@4:1
    Writable : Yes
    Capacity : 149.0 GB (160,022,790,144 Bytes)
    Owners Enabled : No
    Can Turn Owners Off : No
    Can Be Formatted : No
    Bootable : No
    Supports Journaling : No
    Journaled : No
    Disk Number : 4
    Partition Number : 1
    so it looks like a whole lot of no's that need to be turned around! I can't understand why it won't be read by either Mac or PC with all of this, or how I can fix it

  • Need help with simple problem.......

    Hello, I'm fairly new to Java, taking my first year in it. I have a little applet that I have to write up but I'm having some difficulties. Someone please help :)
    OBJECTIVE: Print out the following using a FOR loop.
    OUTPUT:
    JavaProgramming
    JavaProgramming
    JavaProgramming
    JavaProgramming
    JavaProgramming
    I am really having trouble doing the loop and spacing, so that it would have "JavaProgramming" appear 5 times and automatically indent 2 spaces everytime. I've done a "HSA" Console Program (NOT APPLET) where there are 5 words that are not spaced but when I try to do the same in an applet, it simply wont repeat in the loop. Below is the program where there are 5 words WITHOUT spacing in my applet program, I don't know how to repeat it 5 times and have it space 2 times everytime :(
    public class Test extends Applet
        // Place instance variables here
        public void init ()
        } // init method
        public void paint (Graphics g)
            for (int i = 0 ; i < 5 ; i++)
                g.drawString ("JavaProgramming", 20, 20);
        } // paint method
    } // Test classThis will only show "JavaProgramming" once when i run the program. I need it to show 5 times, with 2 spaces indented every time!

    this:
    g.drawString ("JavaProgramming", 20, 20);
    probably needs to be something like:
    g.drawString("JavaProgramming", 20+(i*10), 20+(i*10));
    i.e: increase x and y pos for each iteration.

  • Need help with simple folder action or script

    I have created an export preset in Lightroom that exports images to a folder called "To Email" on my hard drive, and then automatically attaches those images to a new email in my email client (Mailplane).
    It's a great solution that allows me to send a photo via email with one click from Lightroom. However, I want to take it a step further by creating a folder action or script that automatically deletes the image after it is attached to the email. This will allow me to put the folder somewhere deeper in my file system without having to worry about cleaning it out all the time.
    Unfortunately, I have no experience with Automator or AppleScript. Can you help? Thanks.

    I think you need to rework elements of your workflow.
    For example, you say the export preset creates and sends the email.
    If this is the case, the the logical place to make your change would be to edit that preset action (I don't have Lightroom to know whether this is an option there or not).
    The problem with using a Folder Action is that the Folder Action will trigger when the file is dropped in the folder, but that will be before the email is generated or sent, so you run the risk of deleting the file before it's sent.
    So if you can't edit the export preset to do the deletion I would suggest decoupling the 'send an email' and 'delete file' elements from the Lightroom action - in other word change Lightroom to just export the file, and have a separate folder action that triggers when files are added to that folder. The folder action script can take care of generating the email and sending it out, knowing when the email is sent and therefore when it's safe to delete the file.
    WIthout seeing more of the current workflow it's not easy to be more specific.

  • New to swing :( need help with simple text areas

    i'm trying to make a username and pasword GUI thingy (techinical word) but what i have now is this:-
    import javax.swing.*;
    import javax.swing.text.*;
    import javax.swing.*;
    import javax.swing.text.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.net.URL;
    import java.io.IOException;
    public class swing1 extends JFrame implements ActionListener
         private String newline = "\n";
         protected static final String textFieldString = "JTextField";
         protected static final String passwordFieldString = "JPasswordField";
         protected JLabel actionLabel;
         private JTextField textField;
         private JPasswordField passwordField;
         private Container p; // make a panel to witch the components can be added
         public swing1()
              super("swing1");
              //Create a regular text field.
              textField = new JTextField(10);
              textField.setActionCommand(textFieldString);
              textField.addActionListener(this);
              //Create a password field.
              passwordField = new JPasswordField(10);
              passwordField.setActionCommand(passwordFieldString);
              passwordField.addActionListener(this);
              //Create some labels for the fields.
              JLabel textFieldLabel = new JLabel(textFieldString + ": ");
              textFieldLabel.setLabelFor(textField);
              JLabel passwordFieldLabel = new JLabel(passwordFieldString + ": ");
              passwordFieldLabel.setLabelFor(passwordField);
              //Create a label to put messages during an action event.
              actionLabel = new JLabel("Type text and then Return in a field.");
              actionLabel.setBorder(BorderFactory.createEmptyBorder(10,0,0,0));
              //Lay out the text controls and the labels.
              p=getContentPane(); //get te contant pane of this Swing1 to add the componets to
              p.add("West",textField); //add your fist component, add it west on the dafault borderLayout
              p.add("East",textFieldLabel);// add another component, add it east on the dafault borderLayout
              p.add("South",passwordField);// add it south on the dafault borderLayout
              p.add("North",actionLabel); // add it north on the dafault borderLayout
              setSize(400,100); //make it a bit bigger
              setVisible(true);
              public void actionPerformed(ActionEvent e)
                   Object o = e.getSource();// the component that fired this event
                   if (o == textField)
                        //action from the textField
                   else if (o == passwordField)
                        //action from passwordfield
              public static void main(String[] args)
                                  JFrame frame = new TextSamplerDemo();
                                  frame.addWindowListener(new WindowAdapter()
                                       public void windowClosing(WindowEvent e)
                                                 System.exit(0);
                                                                new swing1(); //make a new instance of your class
    [\code]
    why won't the label on my password field dislay?
    and can you take a look at the end of my code i got it off another program, i want to get rid of the HTML page its trying to access and i want it just to close when i click X
    any help would be briliant
    Ant                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    Since you are new to Swing the first thing I would recommend is to read the tutorial "Creating a Gui with JFC/Swing". I think the Text Component section has a demo on creating a username/password GUI. It can be downloaded at:
    http://java.sun.com/docs/books/tutorial/
    Why doesn't the password field label display? You are not adding it to the container. You add textField, textFieldLabel, passwordField, actionLabel but no passwordFieldLabel.
    Instead of adding a WindowListener and implementing the windowClosing() method, there is an easier way to close the JFrame in JDK1.3. Simply use:
    frame.setDefaultCloseOperation( EXIT_ON_CLOSE );
    The class "TextSamplerDemo" doesn't belong in this class (it must be a demo class you downloaded from somewhere). All the code you need in the main method is:
    JFrame frame = new swing1();
    frame.setDefaultCloseOperation( EXIT_ON_CLOSE );
    Also, by convention classes should be named with the first character of each word capitalized. So you class should be renamed to "Swing1" from "swing1". Also remember to rename the file as the filename and class name must be the same and case does matter.

  • Need help with Itunes problem not being able to put custom made ringtone on iphone 4s.

    My iphone 4s is running iOS7. My windows laptop is running the latest version of itunes, i follow instructions everywhere to get the ringtone i made onto my cellphone and i get stuck where it says to go to the apps tab and then scroll down till you see the apps you have and choose the app that you made the ringtone with. Well when i select apps it just goes to the app store, it doesn't do anything else. How in the world do i get that to come up so i can move the ringtone from the app to my phone??? please help!

    Although WAV files have the same audio coding as an audio CD, a disc full of WAV files does not act like an audio CD; it lacks the indexing and ToC needed in order for a "regular" CD player to play it. As Diane notes, put your WAV files in an iTunes playlist and burn it as an *audio CD.*

  • Need help with simple python script (renaming and moving folder)

    I have this script for use with sabnzbd, what it does is rename all folders in the desired directory, replacing any spaces with dots (example: Movie 2011 HD -> Movie.2011.HD).
    #!/usr/bin/env python2
    workdir = '/media/stuff/movies' #### CHANGE this line to your movie directory
    for path, dirnames, filenames in os.walk(workdir):
    print "path:", path
    for dirname in dirnames:
    if dirname.find(' ') > -1 :
    # Yes, a space in the directory name, so replace it:
    newname = dirname.replace(' ','.')
    fulldirname = path + '/' + dirname
    fullnewname = path + '/' + newname
    print "Rename" , fulldirname, " ", fullnewname
    os.rename(fulldirname, fullnewname)
    What I would like it to do is 1. rename only the movie I run the script on (instead of /media/stuff/movies as above, the entire movie folder), and then 2. move the movie into /media/stuff/movies. Or vice versa! (I'd just prefer not to have it run on the entire movie directory).
    Appreciate any help!

    Just my two cents:
    I would not use walkdir but as usual a combination of find and python.
    A simplified version of the script could look like this:
    #!/usr/bin/python
    # -*- coding: utf8 -*-
    import os, shutil
    # Define target dir
    target_dir = "/media/stuff/movies/"
    # Loop through all found files
    for source_file in os.popen ("find ."):
    # Remove \n
    source_file = source_file[:-1]
    extension = source_file[-3:]
    # Only process video files
    if (extension == 'mkv') or (extension == 'avi') or (extension == 'mp4'):
    target_file = source_file.split('/')
    target = target_file[len(target_file)-1]
    target = target.replace(' ','.')
    shutil.copy (source_file, targetdir + target)
    Of course you might first want to print out instead of really copy files.

Maybe you are looking for

  • USER STATUS at Activity Level

    I do have user status defined for Activity and it doesn't show up when i set the status. All i see is SYSTEM STATUS and not user status. To see user status i need to click the blue button (with I symbol) and then see it. Why is this happening like th

  • Key Mapping for Forms

    Hi All, I have 100+ forms, I want to disable some keys in them. e.g. Key-Menu, key-duprec. I can not put a trigger with trigger text 'null;' in each form or inherit an object group and generate again. Can I do something global to remove these key map

  • DVD's burning low contrast

    Why are my DVD's burning in low contrast (with a lifted pedestal/black level)? The contrast is higher when viewing the movie on Quick time and iDVD player. Any thoughts? Drive? DVD's? I'm using Maxell printable DVD's.

  • Where is Default Page stored in Database?

    Could anyone direct me to where a users default page is stored in the database? Thanks

  • PROBLEM MED AT AFINSTALLERE CREATIVE CLOUD + APPS

    Hejsa Jeg har problemer med at afinstallere creative cloud og apps på mac. Jeg har forsøgt at bruge afinstallere via adobe uninstall etc. Men jeg får besked om, at der er slettet noget fra Adobe på min computer. For nylig har jeg tømt min papirkurv,