Having trouble compiling

I am a total newbie at programming and I am having trouble compiling. In the MS-DOS prompt, I located the folder where my .java file is located and typed the following:
javac SampleProgram.java
I received a "Bad command or file name" error. I am typing the names correctly. I am using Java 2 SDK, Standard Edition Version 1.3.1. Am I doing something wrong?
Thanks for any help.

That should fix it. The problem is that DOS needs to know where to find the executable files like javac.exe
You can either set the path temporarily by typing
SET PATH=.;c:\jdk1.3.1\bin
at the command prompt each time you open a command window, or you can set it more permanently by adding it to your startup config. This will depend on your OS. On win 98 for example, there is an AUTOEXEC.BAT (usually with a SET PATH command already present). You could open this in notepad to add/change:
SET PATH=C:\WINDOWS
to
SET PATH=C:\WINDOWS;.;C:\JDK1.3.1\BIN
Reboot to make the changes take effect. Other OS's may have a special dialog to set this kind of command.
Hope this helps some.

Similar Messages

  • FDM mail app - having trouble compiling 1.6 anyone have 1.6 package??

    Hi... sorry to be writing about fdm again.
    http://aur.archlinux.org/packages.php?ID=7806
    I'm having trouble getting 1.6 installed.
    I'm still hoping that the bug fixes in the recently release update for tdb might spark an ARCH version of fdm 1.6.
    I need fdm 1.6 as the current version 1.4-1 does some weird things with gmail and it's about 16 moths old. There's been a version 1.6 since xmas.
    Anyways, sorry to be wimpering.
    Anyone have a 1.6 working?
    Last edited by yvonney (2009-03-07 09:01:54)

    I can now use ABS well enough.
    Noticed the bug repor and now that  tdb has just been updated, and, I assume the bug is gone... I'm wondering:
    - should I wait for new version 1.6 to show up?
    - If anyone has a PKGBUILD for 1.6 that will work just lke it will when the package is updated to 1.6 and in AUR.
    I think that if I were to just download the package and install I'd not only lose the pacman sync ability (wouldn't I?) and that also the locations for the files would be a bit off, and then there's that tip  I got (thanks!) about "make -j1".
    hmmm... really need the 1.6 bug fixes.
    Of course, there's lots else to do.... and I'm very patient...! hehehe
    Just loving mutt and looking forward to fdm 1.6
    um, obviously!

  • Having trouble compiling libdrm

    checking for PTHREADSTUBS... configure: error: Package requirements (pthread-stubs) were not met:
    No package 'pthread-stubs' found
    Consider adjusting the PKG_CONFIG_PATH environment variable if you
    installed software in a non-standard prefix.
    Alternatively, you may set the environment variables PTHREADSTUBS_CFLAGS
    and PTHREADSTUBS_LIBS to avoid the need to call pkg-config.
    See the pkg-config man page for more details.
    Would anyone know how to fix this? I'm having horrible slowness with the intel driver, so i thought id compile it and see if that helps..but I get this error when trying to compile libdrm.

    uploaded pkgbuilds if you want them:
    http://konni.giev.de/intel/
    if you are lazy, there are packages as well.
    ps: those pkgbuilds are far from perfect (basically i just replaced the version in the ones from abs) but seem to work

  • HELP! Having Trouble Compiling my Programs

    I am designing an application based solely on java, where the user is allowed to choose from a list of selected programs and then see the corresponding code in a textarea. I have my code entering into the textarea fine but when i want the code inside the textarea to compile and eventually execute, i cannot get it to work. i have the 'compile' and 'run' as buttons on my toolbar.
    below i have included a web site address describing what i would like to do. It works on much the same basis except i am not using turtle graphics. i would appreciate some feedback on this, and some code would be an added bonus to tackle my problem. i have spent hours on this problem but still no further.
    http://www.otherwise.com/Jurtle.html
    I have also been looking at the classpath and making changes but still no luck. i have decided to include this as well as it might be the root to the problem. My programs are compiling fine in JCreator, but thats using jdk1.3.1, and as you can see from the code below i am now using jdk1.4 in JBuilder. This shouldn't cause an overlap problem should it?
    Below is some of the code i have been working on:
    public void jButtonCompile_actionPerformed(ActionEvent e) {
            try {
    String[] execArray = new String[7];
                            String classpath = new String();
                             execArray[0] = "c:/JBuilderX/jdk1.4/bin/javac.exe";
                             execArray[1] = "-deprecation";
                             execArray[2] = "-classpath";
                            execArray[3] = classpath.toString();
                             execArray[4] = "-sourcepath";
                             execArray[5] = "c:/Thesis/lib";
                           execArray[6] = "GUIcolor.java";
                           Process p = Runtime.getRuntime().exec(execArray);
    catch (IOException ex) {
                System.out.println(ex);
        }.;C:\PROGRA~1\JMF21~1.1\lib\sound.jar;C:\PROGRA~1\JMF21~1.1\lib\jmf.jar;C:\JBuilderX\jdk1.4\src.jar;C:\JBuilderX\jdk1.4\lib\tools.jar;

    Give this a look:
    http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html
    MOD

  • Having trouble compiling netmap kernel module

    Hey everyone,
    First time poster here. Hopefully this question isn't too stupid but I've been having a hard time figuring this out.
    I'm trying to install the netmap drivers for Arch. I've downloaded the header files through pacman, but the configure script for netmap spits out an error stating it requires the full kernel source.
    This is where I'm unsure of what to do. I've gone to kernel.org and downloaded this tar ball: http://mirrors.kernel.org/archlinux/sou … src.tar.gz
    I unpacked it to /usr/src/ and, as instructed in the configure script's error, I run the script with an option to point to the kernel source as such:
    ./configure --kernel-sources=/usr/src/linux/
    ********************************** ERROR **********************************
    *** Cannot find full kernel sources.
    *** We need the full kernel sources to build the netmap-enabled drivers.
    *** Please note that most distributions provide separate packages for kernel
    *** headers and sources. Once you know the path to kernel sources, you can
    *** rerun this script with the additional
    *** --kernel-sources=/path/to/sources
    *** option.
    *** If you are only interested in VALE and pipes, you can rerun the script
    *** now with the '--no-drivers' option. Hardware devices will then be accessed
    *** via a generic adapter at reduced performance."
    *** Current configuration values:
    *** kernel directory /lib/modules/3.18.6-1-ARCH/build
    *** [/usr/lib/modules/3.18.6-1-ARCH/build]
    *** linux version 31206 [3.18.6]
    *** module file netmap.ko
    *** subsystems generic monitor pipe vale
    *** no-drivers
    But it keeps giving me the same error! Did I not download the kernel source? I feel like I'm so close...
    - Cory
    Last edited by burning_flag (2015-03-19 05:28:36)

    Step by Step to fix your Mac

  • Having trouble Compiling using Textpad editor???

    Hi, I Knew to java as well as computers and I need help? I downloaded the java kit and was using textpad as a text editor and every time i tried to compile it said it couldn't find my file, even though I just finished typing it??? Even when I to run in textpad it gives me the same message it gives everyone else "exception in "main" thread etc.; What is this classpath stuff? What do i do with it? If anyone can e-mail me or post the typing and steps on the forum I will very appreciative.Thanks again for your help. e-mail is [email protected]

    I'll rephrase my description.
    For win98:
    1)Click start button
    2)Click Run and Type msconfig
    3) Select Autoexec tab and click 'New' if CLASSPATH variable is not present.
    4) For new entry key in "CLASSPATH=C:\<jdk directory>\jre\lib\rt.jar"
    * your jdk directory will either be jdk1.3 or jdk1.2
    Click Ok and Reboot
    For win2k or XP
    1)Right click on my computer icon on your desktop
    2)Select Properties
    3)Click on the advanced tab
    4)Click on environment variables
    5)Under system variables at the bottom click 'New' if CLASSPATH variable is not present
    6)For varibale name key in CLASSPATH
    7)For variable value key in C:\<jdk directory>\jre\lib\rt.jar
    * your jdk directory will either be jdk1.3 or jdk1.2
    Click ok and You do not need to reboot
    You should be able to compile your java code in textpad after completion of the appropriate steps above.

  • Having trouble compiling this file reader program!!

    Hi,
    I wrote this program to read a flat file so I can parse it thereafter. I'm not sure where I need to change syntax.
    If need be, I can send the error msg.
    Thanks in advance!!
    import java.io.*;
    class FileReader1
         public String readLine() throws IOException
              try {
                   //FileReader br = new FileReader(new
                   //File("C:\\Shared CLM\\netsvc.txt")) ;
                   LineNumberReader lnr = new LineNumberReader(new FileReader(
                   "C:\\Shared CLM\\netsvc.txt")) ;
                   String line = lnr.readLine() ;
                   //switch() {...}
                        lnr.close() ;
                        //br.close() ;
                   } catch (IOException e) {
                                  e.printStackTrace();
    }

    Well, I removed the ";" but I am still getting 9 errors...
    C:\mail\CLM Mail Program\Ballb.java:6: ';' expected
         public String readLine() throws IOException
    ^
    C:\mail\CLM Mail Program\Ballb.java:6: missing method body, or declare abstract
         public String readLine() throws IOException
    ^
    .\FileReader.java:7: ';' expected
    public String readLine() throws IOException
    ^
    .\FileReader.java:28: '}' expected
    ^
    .\FileReader.java:7: cannot resolve symbol
    symbol : class IOException
    location: class FileReader
    public String readLine() throws IOException
    ^
    C:\mail\CLM Mail Program\Ballb.java:13: cannot resolve symbol
    symbol : constructor FileReader (java.lang.String)
    location: class FileReader
              {LineNumberReader lnr = new LineNumberReader(new FileReader("C:\\Shared CLM\\netsvc.txt")) ;
                                                                 ^
    C:\mail\CLM Mail Program\Ballb.java:14: cannot resolve symbol
    symbol  : variable line 
    location: class Ballb
              line = lnr.readLine() ;
                    ^
    C:\mail\CLM Mail Program\Ballb.java:21: return outside method
                   return line;
                            ^
    .\FileReader.java:7: missing method body, or declare abstract
    public String readLine() throws IOException
                  ^
    9 errors                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Trouble compiling for printed documentation

    hello, i am having trouble compiling a new document layout i
    have created, i have followed peter grainges instructions on his
    website but it always fails to generate straight away. Im using
    Robohelp x5 with word 2000, does anyone have any ideas?
    thanks steve

    Steve
    Was RH installed on the PC you are using with you logon or
    that of the person whose job you have taken over? It sounds very
    much like the latter and this is exactly what I would expect to
    happen.
    Try creating a new project with just a couple of topics and
    printing from that. It will likely also fail. If it does that
    pretty much confirms my theory. Uninstall and reinstall RH with
    your logon and with admin rights attached and the problem will
    likely go away.

  • Just downloaded jGRASP, and having problems compiling...

    I just downloaded jGRASP, and I am having trouble compiling my code. I think I might need to download some compiler, but im not sure what exactly to download (in order to properly compile and run my coude) and where to get it. thanks for your help!

    Please refrain from cross-posting (posting the same thread into multiple forums).
    Thank you.
    http://forum.java.sun.com/thread.jspa?threadID=770482&tstart=0

  • Having trouble with rounding and if/else

    I am trying to write a program that reads 2 floating-point numbers and test if they're the same when rounded to 2 decimal places and whether they diff by less than 0.01. I'm having trouble compiling it, with errors such as
    "C:\Documents and Settings\John\My Documents\Test2.java:24: 'else' without 'if' else"
    C:\Documents and Settings\John\My Documents\Test2.java:18: cannot find symbol
    symbol  : method round(double,int)
    location: class java.lang.Math
         double round1 = Math.round(firstinput,2);
                             ^
    C:\Documents and Settings\John\My Documents\Test2.java:19: cannot find symbol
    symbol  : method round(double,int)
    location: class java.lang.Math
         double round2 = Math.round(secondinput,2);Here is the code:
    import java.util.Scanner;
    import java.text.NumberFormat;
    import java.math.*;
    import java.lang.Math;
    public class Test2
         public static void main( String args[] )
         Scanner sc = new Scanner( System.in);
         System.out.println("Enter your first floating-point number: ");
         double firstinput = sc.nextDouble();
         System.out.println("Enter your second floating-point number: ");
         double secondinput = sc.nextDouble();
         double round1 = Math.round(firstinput,2);
         double round2 = Math.round(secondinput,2);
         double total = round1 - round2;
        if(round1 == round2);
        System.out.print("They are the same when rounded to two decimal places. \n");
        else
        System.out.print("They are not the same when rounded to two decimal places. \n");
         if(total<1.01 && total>0.99)
         System.out.print("They differ by less than 0.01. \n");
         else
         System.out.print("They do not differ by less than 0.01. \n");
    }

    Are you restricted to Math.round()? Try reading about DecimalFormat:
    http://java.sun.com/j2se/1.4.2/docs/api/java/text/DecimalFormat.html
    Your code with DecimalFormat:
    import java.text.DecimalFormat;
    import java.util.Scanner;
    public class Test2 {
        public static void main(String[] args) {
            DecimalFormat df = new DecimalFormat("#.##");
            Scanner sc = new Scanner( System.in);
            System.out.println("Enter your first floating-point number: ");
            double firstinput = sc.nextDouble();
            System.out.println("Enter your second floating-point number: ");
            double secondinput = sc.nextDouble();
            double round1 = Double.parseDouble(df.format(firstinput));
            double round2 = Double.parseDouble(df.format(secondinput));
            double total = round1 - round2;
            if(round1 == round2)
                System.out.print("They are the same when rounded to two decimal places. \n");
            else {
                System.out.print("They are not the same when rounded to two decimal places. \n");
                if(total<1.01 && total>0.99) //<== Rather redundant, why not just use total == 1
                    System.out.print("They differ by less than 0.01. \n"); //<== From the above if statement, it seems if you are looking to see if the 2 numbers differ by less than 1.00, and not 0.01. The same goes for the else statement below
                else
                    System.out.print("They do not differ by less than 0.01. \n");
    }Also, when I ran your program with the latter code and entered two same floating point numbers, it also printed out "They do not differ by less than 0.01." I've added curly brackets around the outer else statement to ensure that it does not happen. It's best to use curly brackets in structured statements if their function exceeds more than one line; for stability and legibility.
    Also, read my comments.

  • I am having trouble burning a gapless album that is a mixed compilation. I have selected part of compilation album on the options tab and I did select gap between songs as zero. When I play the cd, it is sticking between songs? Please help!

    I am having trouble burning a gapless album that is a mixed compilation. I have selected part of compilation album on the options tab and I did select gap between songs as zero. When I play the cd back after burning, it is sticking between songs? Please help!

    sheldz46 wrote:
    Thanks Chris but according to Pioneer, is was possible with the itunes in 2010.
    It wasn't. (at least as far as setting Part of Gapless album goes. See next para.)
    They claim that itunes will work if you select gapless album, part of a compilation
    Selecting Gapless album does not make it gapless. (which is likely that now this option is removed - to not confuse people)
    The ONLY thing that option did was tell iTunes to NOT crossfade consecutive songs from same gapless album IF you had crossfade enabled.
    -> http://support.apple.com/kb/ht1797
    Setting the gap to 0 is what made it "seem" gapless.
    Perhaps it is not working as it used to.
    Try a slower burn speed.
    and used itunes to convert them to mp3
    Dont know why they suggest this.
    Simply use the WAV file. Then there will be no loss (as there is when converted to MP3).

  • I'm having Trouble with a Simple Histogram

    The program as a whole is supposed to read a text file, count the number of words, and ouput it. For example, "The The The pineapple pineapple" should ouput "The 3, Pineapple 2" I've gotten as far as dumping the tokens into an array and creating 2 empty arrays of the same size(word, count), but I don't know how to do the double loop that's necessory for the count. Please see my "hist()" method, this is where I'm having trouble. Any suggestions at all would be greatly appreciated. import java.io.*;
    import java.util.*;
    /*class Entry {
        String word;
        int count;
    class main { 
        public static void main(String[] args){
         main h = new main();
         h.menu();
        String [] wrd;
        String [] words;
        int[] count;
        int wordcount = 0;
        int foundit = -1;
        int size;
        int numword = 0;
        int i = 0;
        int j = 0;
        int elements = 0;
        public void menu() {
          System.out.println("Welcome to Histogram 1.0");
          BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
          while(true){
              System.out.println("Please enter one of the following commands: open, hist, show, save, help, or quit");
              String s = null;
              try {s = in.readLine();} catch (IOException e) {}
              if (s.equals("open")) open();
              else if (s.equals("hist")) hist();
              else if (s.equals("show")) show();
              else if (s.equals("save")) save();
              else if (s.equals("help")) help();
              else if (s.equals("quit")) {
                  System.exit(0);
         public void open(){
         // prompt user for name of file and open it
         System.out.println("Enter Name Of File: ");
         BufferedReader in = new BufferedReader(new InputStreamReader (System.in));
         String filename = null;
         try{ filename = in.readLine();}
         catch(IOException e)  {}
         BufferedReader fin = null;
         try { fin = new BufferedReader (new FileReader(filename));}
         catch (FileNotFoundException e){
             System.out.println("Can't open file "+filename+" for reading, please try again.");
             return;
         // read file for 1st time to count the tokens
         String line = null;
         try{ line = fin.readLine();}
         catch(IOException e) {}
         StringTokenizer tk = new StringTokenizer(line);
         while(line!= null){
             try{ line = fin.readLine();}
             catch(IOException e) {}
             //tk = new StringTokenizer(line);
             wordcount += tk.countTokens();
             System.out.println("wordcount = " + wordcount);
         // close file
         try{fin.close();}
         catch(IOException e){
             System.out.println( filename+" close failed");
         // now go through file a second time and copy tokens into the new array
         wrd = new String [wordcount];
            BufferedReader fin2 = null;
            try{ fin2 = new BufferedReader (new FileReader(filename));}
            catch(FileNotFoundException e){
                System.out.println("Can't open file "+filename+" for reading, please try again.");
                return;
            String pop = null;
            try{ pop = fin2.readLine();}
            catch(IOException e) {}
            StringTokenizer tk2 = new StringTokenizer(pop);
         int nextindex = 0;
         while(pop!=null){
             while (tk2.hasMoreTokens()) {
              wrd[nextindex] = tk2.nextToken();
              nextindex++;
             try{ pop = fin2.readLine();}
             catch(IOException e) {}
             //tk2 = new StringTokenizer(pop);
         try{fin2.close();}
         catch(IOException e){
             System.out.println(filename+" close failed");
         for(int k=0;  k<wordcount; k++){
            System.out.println(wrd[k]);
        public void hist() {
            //prints out all the tokens
           words = new String[wordcount];
           count = new int[wordcount];
           //boolean test = false;
               for(int m=0; m<wordcount; m++){
                   if(words.equals(wrd[m])){
                       System.out.print("match");        
                   else{
                       words[m] = wrd[m];
                       count[m] = 1;
        public void show() {
         //shows all the tokens
         for(int j=0; j<wordcount; j++){
              System.out.print(words[j]);
              System.out.print(count[j]);
        public void save() {
            //Write the contents of the entire current histogram to a text file
            PrintWriter out = null;
            try { out = new PrintWriter(new FileWriter("outfile.txt"));}
            catch(IOException e) {}
            for (int i= 0; i<wordcount; i++) {
                out.println(words);
    out.println(count[i]);
    out.close();
    public void help() {
    System.out.println(" This help will tell you what each command will do.");
    System.out.println("");
    System.out.println(" open - this command will open a text file that must be in the same directory ");
    System.out.println(" as the program and scan through it counting how many words it has, ");
    System.out.println("");
    System.out.println(" hist - after you use the open command to open the text file the hist command will ");
    System.out.println(" make a tally sheet counting how many times each word has been used. ");
    System.out.println("");
    System.out.println(" show - after you have opened the file with the open command and created a histogram ");
    System.out.println(" with the hist command the show command will show a portion of or the entire h histogram. ");
    System.out.println("");
    System.out.println(" (show) just by itself will show the entire histogram. ");
    System.out.println("");
    System.out.println(" (show abc) will show the histogram count for the text abc if it exists. ");
    System.out.println(" If the text is not found it will display text not found. ");
    System.out.println("");
    System.out.println(" (show pr*) will show the histogram count for all text items that begin with ");
    System.out.println(" the letters pr, using * as a wild card character. ");
    System.out.println("");
    System.out.println(" save - after you have opened the file with the open command, and created the histogram ");
    System.out.println(" with the hist command the save command will save the contents of the entire current histogram. ");
    System.out.println(" to a text file that you choose the name of. If the file already exists the user will be prompted ");
    System.out.println(" for confirmation on if they want to pick another name or overwrite the file.");
    System.out.println("");
    System.out.println(" quit - will quit the program. " );

    Couple of points to begin with:
    1. Class names should begin with an upper case letter
    2. Class names should be descriptive
    3. You shouldn't call your class main (this kind of follows from the first two points).
    4. Always use {} around blocks of code, it will make your life, and those of the people who have to eventually maintain your code a lot easier.
    5. Never ignore exceptions, i.e. don't use an empty block to catch exceptions.
    6. Avoid assiging a local variable to null, especially if the only reason you are doing it is to "fix" a compilation error.
    7. Your method names should reflect everything that the method does, this should encourage you to break the application logic down into the smallest tasks possible (a general rule is that each method should do one task, and do it well). In the example below, I ignore this advice in the loadFile() method, but it's left as an exercise to you to fix this.
    8. You should use descriptive variable names (fin may make sense now, but will it in 6 months time?), and use camel case where the name uses multiple words, e.g. wordcount should be wordCount
    On the problem at hand, I'll post a cut down example of what you want, and you can look at the javadocs, and find out how it works.
    This code uses the auto-boxing feature of 1.5 (even though I don't like it, again it's left as an exercise for you to remove the auto-boxing ;) ) and some generics (you should be able to work out how to use this code in 1.4).
    import java.io.BufferedReader;
    import java.io.FileNotFoundException;
    import java.io.FileReader;
    import java.io.IOException;
    import java.io.InputStreamReader;
    import java.util.HashMap;
    import java.util.Map;
    import java.util.StringTokenizer;
    public class Histogram {
        /** Map to box the words. */
        private Map<String, Integer> wordMap = new HashMap<String, Integer>();
         * Main method.
         * @param args
         *        Array of command line arguments
        public static void main(String[] args) {
            Histogram h = new Histogram();
            h.menu();
         * Display the menu, and enter program loop.
        public void menu() {
            System.out.println("Welcome to Histogram 1.0");
            BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
            while (true) {
                System.out.println("Please enter one of the following commands: open, hist, show, save, help, or quit");
                String s = null;
                try {
                    s = in.readLine();
                } catch (IOException e) {
                    System.out.println("Unable to interpret the input.");
                    continue;
                if (s.equals("open")) {
                    loadFile();
                } else if (s.equals("quit")) {
                    System.exit(0);
         * Ask the user for a file name and load it
        public void loadFile() {
            System.out.println("Enter Name Of File: ");
            BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
            String filename = null;
            try {
                filename = reader.readLine();
                reader = new BufferedReader(new FileReader(filename));
                loadWords(reader);
                reader.close();
            } catch (FileNotFoundException e) {
                System.out.println("Can't open file " + filename + " for reading, please try again.");
                return;
            } catch (IOException e) {
                System.out.println(filename + " close failed");
            displayHistogram();
         * Load the words from the file into the map.
         * @param reader
        private void loadWords(BufferedReader reader) {
            int wordCount = 0;
            try {
                String line = reader.readLine();
                while (line != null) {
                    StringTokenizer tk = new StringTokenizer(line);
                    wordCount += tk.countTokens();
                    while (tk.hasMoreTokens()) {
                        String next = tk.nextToken();
                        if (wordMap.containsKey(next)) {
                            wordMap.put(next, (wordMap.get(next).intValue() + 1));
                        } else {
                            wordMap.put(next, 1);
                    System.out.println("line: " + line + " word count = " + wordCount);
                    line = reader.readLine();
            } catch (IOException e) {
                System.out.println("Unable to read next line");
         * Display the words and their count.
        private void displayHistogram() {
            System.out.println("Map of words: " + wordMap);
    }

  • Trouble compiling code

    I'm trying to write a rock, paper, scissors program but am having trouble converting an integer to its appropriate string. Here is the code I have:
    // Rock.java
    // Play Rock, Paper, Scissors with the user
    import java.util.Scanner;
    import java.util.Random;
    public class Rock
    public static void main(String[] args)
         String personPlay; //User's play -- "R", "P", or "S"
         String computerPlay; //Computer's play -- "R", "P", or "S"
         int computerInt; //Randomly generated number used to determine
         //computer's play
    Scanner scan = new Scanner(System.in);
         Random generator = new Random();
         computerInt = generator.nextInt(3);//Generate computer's play (0,1,2)
         //Translate computer's randomly generated play to string
         switch (computerInt)
         case 0:
              System.out.println ("R");
              break;
         case 1:
              System.out.println ("P");
              break;
         case 2:
              System.out.println ("S");
              break;
    System.out.println ("Enter your play: R, P, or S");//Get player's play from input-- note that this is stored as a string
    personPlay = scan.nextLine();
    personPlay = personPlay.toUpperCase();     //Make player's play uppercase for ease of comparison
    System.out.println ("Computer play is " + computerPlay);     //Print computer's play
         //See who won. Use nested ifs instead of &&.
         if (personPlay.equals(computerPlay))
         System.out.println("It's a tie!");
         else
              if (personPlay.equals("R"))
                   if (computerPlay.equals("S"))
                   System.out.println("Rock crushes scissors. You win!!");
              if (computerPlay.equals("P"));
                   System.out.println("Paper covers rock. You lose");
                   if (personPlay.equals("P"))
                        if (computerPlay.equals("R"))
                        System.out.println("Paper covers rock. You win!!");
                        if (computerPlay.equals("S"))
                                  System.out.println("Scissors cuts paper. You lose");
                   if (personPlay.equals("S"))
                             if (computerPlay.equals("R"));
                                       System.out.println("Rock crushes scissors. You lose");
                             if (computerPlay.equals("P"))
                             System.out.println("Scissors cuts paper. You win!!");
              //... Fill in rest of code
    My compiling error is that the string computerPlay was not initialized.. I think I need to do something more in the switch section of the code but can't figure out what. Thanks ahead of time for any advice!

    soccer89 wrote:
    My compiling error is that the string computerPlay was not initialized.. I think I need to do something more in the switch section of the code but can't figure out what. Thanks ahead of time for any advice!Instead of running System.out.println() set the value in your switch statementl then run
    System.out.println(computerPlay);after it's properly set.
    BTW, rather than a switch statement, you could use
    computerPlay = "RPS".substring(computerInt, computerInt + 1);I'll leave you to work out why.
    Winston

  • Trouble compiling a library

    Hi folks, I'm experiencing a trouble using forms & reports on two different platforms: Win XP Prof. SP2 for development and SuSe Ent. 9 Linux for deployment.
    I've inherited from another person an application with some forms, some reports and two libraries (one attached to the forms annd the other attacched to the reports).
    I've modified a function in the library attacched to the reports. It compiles ok on XP.
    Moved the library (.pll file) to Suse I tried to compile with:
    #!/bin/sh
    PATH_SAVE=$PWD
    ORACLE_HOME=/opt/oracle/app/oracle/product/frs10.1.2
    export ORACLE_HOME
    FORMS_PATH=/opt/csa/sw/webapp/FORMS:/opt/csa/sw/webapp/CSA_LIBS
    export FORMS_PATH
    REPORTS_PATH=/opt/csa/sw/webapp/REPORTS:/opt/csa/sw/webapp/CSA_LIBS
    export REPORTS_PATH
    TNS_ADMIN=$ORACLE_HOME/network/admin
    export TNS_ADMIN
    TWO_TASK=csa_v30/csa_v30@csa5i009
    export TWO_TASK
    ORACLE_SID=csa5i009
    export ORACLE_SID
    LD_LIBRARY_PATH=$ORACLE_HOME/jdk/jre/lib/i386/server:$ORACLE_HOME/jdk/jre/lib/i386/native_threads:$ORACLE_HOME/jdk/jre/lib/i386:$ORACLE_HOME/lib
    export LD_LIBRARY_PATH
    ORACLE_TERM=vt220
    export ORACLE_TERM
    # COMPILE LIBRARIES
    cd /opt/csa/sw/webapp/CSA_LIBS
    $ORACLE_HOME/bin/frmcmp_batch module=LIB_CSA_FORMS.pll userid=csa_v30/csa_v30@csa5i009 module_type=LIBRARY compile_all=YES logon=YES batch=YES
    # COMPILE FORMS and MENUS
    cd /opt/csa/sw/webapp/FORMS
    for file in *.fmb
    do
    $ORACLE_HOME/bin/frmcmp_batch module=$file userid=csa_v30/csa_v30@csa5i009 module_type=FORM compile_all=YES logon=YES batch=YES
    done
    for file in *.mmb
    do
    $ORACLE_HOME/bin/frmcmp_batch module=$file userid=csa_v30/csa_v30@csa5i009 module_type=MENU compile_all=YES logon=YES batch=YES
    done
    cd $PATH_SAVE
    unset PATH_SAVE
    and obtained:
    PL/SQL ERROR 201 at line 58, coloumn 5
    identifier 'SRW.SET_FOREGROUND_FILL COLOR' must be declared
    FRM-30312: Failed to compile the library
    Some useful data:
    Forms [32 Bit] Version 10.1.2.0.2 (Production)
    Oracle Toolkit Version 10.1.2.0.2 (Production)
    PL/SQL Version 10.1.0.4.2 (Production)
    Oracle Procedure Builder V10.1.2.0.2 - Production
    PL/SQL Editor (c) WinMain Software (www.winmain.com), v1.0 (Production)
    Oracle Query Builder 10.1.2.0.2 - Production
    Oracle Virtual Graphics System Version 10.1.2.0.2 (Production)
    Oracle Tools GUI Utilities Version 10.1.2.0.2 (Production)
    Oracle Multimedia Version 10.1.2.0.2 (Production)
    Oracle Tools Integration Version 10.1.2.0.2 (Production)
    Oracle Tools Common Area Version 10.1.2.0.2
    Oracle CORE     10.1.0.4.0     Production
    And:
    Report Builder 10.1.2.0.2
    ORACLE Server Release 10.1.0.4.2
    Oracle Procedure Builder 10.1.2.0.2
    Oracle ORACLE PL/SQL V10.1.0.4.2 - Production
    Oracle CORE     10.1.0.4.0     Production
    Oracle Tools Integration Services 10.1.2.0.2
    Oracle Tools Common Area 10.1.2.0.2
    Oracle Toolkit 2 for Windows 32-bit platforms 10.1.2.0.2
    Resource Object Store 10.1.2.0.2
    Oracle Help 10.1.2.0.2
    Oracle Sqlmgr 10.1.2.0.2
    Oracle Query Builder 10.1.2.0.2 - Production
    PL/SQL Editor (c) WinMain Software (www.winmain.com), v1.0 (Production)
    Oracle ZRC 10.1.2.0.2
    Oracle XML Developers Kit 10.1.0.4.2 - Production
    Oracle Virtual Graphics System 10.1.2.0.2
    Oracle Image 10.1.2.0.2
    Oracle Multimedia Widget 10.1.2.0.2
    Oracle Tools GUI Utilities 10.1.2.0.2
    Any advice will be welcome
    Thanx
    Rob

    This package currently compiles fine with the latest gcc (at least last time I checked), but still I'm having trouble making a package for it because I don't know how to get it to install to a custom location like the $startdir/pkg directory.

  • Having trouble with an else statement.........

    I am having trouble figuring out what to do with this else statement error.........I can't seem to see where I am going wrong...............can anyone help? I can compile it but I just keep getting this one error I can't fix.....................
    Program Name:     Transfer
    import java.io.*;
    import java.awt.*;
    import java.awt.event.*;
    public class Transfer extends Frame implements ActionListener
    DataOutputStream output;
    //Construct components
    Panel dataFields = new Panel();
    Panel firstRow = new Panel();
    Panel secondRow = new Panel();
    Panel thirdRow = new Panel();
    Panel fourthRow = new Panel();
    Panel buttonArea = new Panel();
    Button submit = new Button("Submit");
    Button exit = new Button("Exit");
    Label firstNameLabel = new Label("Name:");
    TextField firstName = new TextField(15);
    Label studentIdLabel = new Label("Student ID:");
    TextField studentId = new TextField(15);
    Label transferCourseLabel = new Label("Transfer Course Number:");
    TextField transferCourse = new TextField (15);
    Label localCourseLabel = new Label("Local Course Number:");
    TextField localCourses = new TextField (15);
    public static void main(String args[])
    Transfer window = new Transfer();
    window.setTitle("Transfer Course Substitutions");
    window.setSize(450, 250);
    window.setVisible(true);
    public Transfer()
    //set backgound and layout managers
    setBackground(Color.magenta);
    setLayout(new BorderLayout());
    dataFields.setLayout(new GridLayout(4,2));
    FlowLayout rowSetup = new FlowLayout(FlowLayout.LEFT,4,2);
    firstRow.setLayout(rowSetup);
    secondRow.setLayout(rowSetup);
    thirdRow.setLayout(rowSetup);
    fourthRow.setLayout(rowSetup);
    buttonArea.setLayout(new FlowLayout());
    //Add fields to rows
    firstRow.add(firstNameLabel);
    secondRow.add(studentIdLabel);
    thirdRow.add(transferCourseLabel);
    fourthRow.add(localCourseLabel);
    //Add rows to panel
    dataFields.add(firstRow);
    dataFields.add(secondRow);
    dataFields.add(thirdRow);
    dataFields.add(fourthRow);
    //Add buttons to panel
    buttonArea.add(submit);
    buttonArea.add(exit);
    //Add panels to frame
    add(dataFields, BorderLayout.NORTH);
    add(buttonArea, BorderLayout.SOUTH);
    //Add functionality to buttons
    submit.addActionListener(this);
    exit.addActionListener(this);
    // output states
    try
    output = new DataOuputStream(new FileOUtputStream("Transfer.dat"));
    catch(IOException ex)
    System.exit(1);
    //construct window listener
    addWindowListener(
    new WindowAdapter()
    public void windowClosing(WindowEvent e)
    System.exit(0);
    public void actionPerformed(ActionEvent e)
    String arg = e.getActionCommand();
    if (arg == "Submit")
    try
    output.writeUTF(code);
    output.writeUTF(firstName.getText());
    output.writeUTF(studentId.getText());
    output.writeUTF(transferCourse.getText());
    output.writeUTF(localCourse.getText());
    catch(IOException ex)
    System.exit(1);
    clearFields();
    else //code to execute if the user clicks Exit
    try
    output.close();
    catch(IOException c)
    System.exit(1);
    System.exit(0);
    public void clearFields()
    firstName.setText("");
    studentId.setText("");
    transferCourse.setText("");
    localCourse.setText("");
    firstName.requestFocus();

    The == method does work but it compares Object references and not the String contents. If the string you are comparing is actually the same object it will reply with 'true' also id both Strings are generated with quotes in the same methos and they contain the same string it will also work. This because the compiler will optimize your creating 2 identical Strings to 1 crete statement.
    String a = "Hello";
    String b = "Hello";
    String c = new String("Hello");
    String d = "He" + "llo";
    String e = "He";
    e +="llo";
    a == b ==> true : because of optimization
    a == c ==> false: because of different objects
    a.equals(c) ==> true
    a == d ==> true : because of optimization
    a == e ==> false : because of different objects

Maybe you are looking for

  • Itunes Installs Correctly But wont open new development

    Hello I posted previously about this same problem. Here is a quick review: have downloaded the latest version of iTunes for Windows XP and I installed it correctly yet when I attempt to open it the hourglass appears for a second and then disappears a

  • HT204088 print all purchase history. How can I do this?

    I need print all purchase history of itunes, with the date, description and value of each purchase. How can I do this?? I can see in my account/history purchase/see all .... but first I can not to see the complete value, this is clipped; second here

  • Using non blocking connect() call for SCTP sockets in Solaris10

    Hi, I have a problem with non blocking connect call on SCTP socket. I am using the sctp stack support in Solaris10. When the connect is successful, I can get the pollout event on the socket. But there is no event observed when the peer does not exist

  • Premiere pro cs6 - volumes/disk.........Splitter_Buffer.cpp-70 error

    Hi, i am running premiere pro cs6 and any time i previw clips or try any play back i get this error, even in new blank projects? does anyone have any ideas? running mac mavericks Nvidia GTX770 premiere pro 6.0.5 thanks a lot paul

  • Hyperion Essbase User's Guide

    Hello, I am looking for a softcopy of Hyperion essbase 6.5 User's Guide. I would appreciate if someone can help me find one. Thanks. Vijay