Getting a program to compile on a mac

hi i am really new at java, and I would like to know how to get a program to compile. The book I have mentioned something confusing about a javac file in the bin directory, and I found that in my library, But if that is the compiler then I have absolutely no idea how to make my programs compile with that.
Also if someone could generally explain the compiling process to me that would rock
Thanks people

Java is an interpreted language [ like most other languages], it need the Java runtime libraries to execute and the Java compiler to translate your application's code into bits & bytes for the OS to run your application.
all you need is to install all Java Plug ins, and your application can run in a Mac and also Linux, just as long you do not use extensive Hardware-exclusive APIS [ application programming interfaces].
but for most of us beginners it doesn't seem to happen a lot. ;-)
Walter_Rincon

Similar Messages

  • Cannot Get This Program To Compile

    Can someone please review this question and help me to fix the syntax. I will also post the question so that you have an idea of what is going on. I am very frustrated about this problem. I just can't get it to work and I really don't know all of the commands. I am a novice to Java.
    The letters of a word are stored in an array str with the first letter in str(1), the second in str(2), and so on. The character ?$? is placed in the array after the last letter of the word to indicate the end of the word.
    Suppose that str contains m letters (excluding ?$?).
    Write a program to:
    1. Allow the user to read a word into the array str. Assume that there is no word longer than 100 characters.
    2. Read an integer value (n > 0) and a letter, ?letter?. Your program must insert letter after the nth letter in str. The letters to the right of the nth letter (including ?$?) must be shifted right by one position to make room for letter. Validate the value of n.
    3. To delete a letter, 'error', from the word all the letters following 'error' must be shifted left by one position to overwrite 'error'. Your program must prompt the user for the letter 'error' and delete the letter from the word.
    import java.io.*;
    public class Assign5
    public static void main(String[]args) throws IOException
    char str[] = new char[100];
    int count =0;
    BufferedReader read = new BufferedReader (new InputStreamReader (System.in));
    String word;
    String letter;
    String input;
    System.out.println("******Word Count, Formation & Reformation Function******");
    System.out.println("\nEnter your word of choice ending with $ e.g. Scavenger$ ");
    word = read.readLine();
    do
    if (Character.isSpaceChar(word.charAt(count)) == true)
    System.out.println("You forgot the $ to indicate the end of the word");
    System.out.println( "Enter word to which manipulation must be done, ending with $ e.g. Scavenger$");
    word = read.readLine();
    str[count]= word.charAt(count);
    count ++;
    }while (str[count -1] != '$');
    int m = count -1;
    System.out.println("\nThe number of letters in the word is " +m);
    //Word Re-Formation Function
    System.out.println("\nEnter a letter that you wish to stuff into your word");
    letter = read.readLine();
    System.out.println( "\nEnter the letter position (an integer) after which to stuff your letter");
    input = read.readLine();
    int n = Integer.parseInt(input);
    n = n - 1 ;
    while(n <= 0)
    System.out.println("\nI am sorry...that position is invalid");
    System.out.println("\nEnter the letter position (an integer) after which to stuff your letter");
    input = read.readLine();
    n = Integer.parseInt(input);
    n = n-1;
    char temp[] = new char[100];
    int index = 0;
    for(int i = (n+1);i <= m; i++)
    index = index +1;
    temp[index] = str;
    str[n +1] = letter.charAt(0);
    index = 1;
    for(int i = (n+2); i <= (m+1) ; i++)
    str = temp[index];
    index = index + 1;
    //Printing the new word
    System.out.print("\nThe new reconstructed word is: ");
    for(int i = 0; i <= m ; i++)
    System.out.print(str);
    System.out.println();
    int newM = m + 1;
    //Error Correction Module
    System.out.print("\nThe new reconstructed word is: ");
    for(int i = 0; i <= m ; i++)
    System.out.print(str);
    char errorLetter[] = new char[1];
    do
    System.out.println("Enter a letter that you wish to remove from your word");
    input = read.readLine();
    errorLetter[1] = input.charAt(1);
    int position = 0;
    for(int findLetter = 1; findLetter <= newM; findLetter++)
    if(errorLetter[1] == str[findLetter])
    position = findLetter;
    if(position == 0)
    System.out.println("I am sorry?that letter is NOT contained in the word.");
    errorLetter[1] = ' ';
    position = 0;
    }while (errorLetter[1] == ' ');
    System.out.println("The new word formed after removing your letter is: ");
    for(i = 1; i = 100; i++)
    if(i = position)
    str = temp[i + 1];
    for(fillLoop = i + 1; fillLoop = 99; fillLoop++)
    str[fillLoop] = temp[fillLoop + 1];
    for(i = 0; i = 100; i++)
    System.out.print(str[fillLoop]);
    }

    As I'm sure the compiler would help you find out, there are a few problems in this:
    1. You treat str as if it's a single char, when in fact it's a char array (char[]). If you want to copy an element in str to temp, you have to do it like str[i] = temp
    2. You are not properly declaring your variables in your loops. You have to declare every variable before you use it, so this is wrong:
              for (i = 1; i = 100; i++) {
                   if (i = position) {
                        str = temp[i + 1];
                        for (fillLoop = i + 1; fillLoop = 99; fillLoop++) {
                             str[fillLoop] = temp[fillLoop + 1];
              }It should instead be
              for (int i = 1; i = 100; i++) {
                   if (i = position) {
                        str = temp[i + 1];
                        for (int fillLoop = i + 1; fillLoop = 99; fillLoop++) {
                             str[fillLoop] = temp[fillLoop + 1];

  • Can't get my program to compile

    I'm pretty sure I wrote this close to how it should be, but I can't get it to compile. What am I doing wrong?
    File name: TruckTest.java
    This program tests class Truck which has Vehicle as its super class
    Author: Rajan Alex
    import java.util.*;
    public class TruckTest
    public static void main(String[] args){
    Scanner keyboard = new Scanner(System.in);
    String ownerName = "Peggy", brandName = "Volkswagen";
    int towCapacity = 2000, cylinder = 4;
    double loadCapacity = 2.5;
    Truck t1 = new Truck(); // default constructor
    t1.writeOutput(); //default output
    t1.set(ownerName, brandName, cylinder, loadCapacity, towCapacity);
    t1.writeOutput();
    System.out.println("Enter make name:");
    brandName = keyboard.nextLine();
    System.out.println("Enter owner: ");
    ownerName = keyboard.nextLine();
    System.out.println("Enter number of cylinders:");
    cylinder = keyboard.nextInt();
    System.out.println("Enter load capacity:");
    loadCapacity = keyboard.nextDouble();
    System.out.println("Enter tow capacity:");
    towCapacity = keyboard.nextInt();
    t1 = new Truck(ownerName, brandName, cylinder, loadCapacity, towCapacity);
    t1.writeOutput();
    public class Truck extends Vehicle{
    private double load;
    private int tow;
    public Truck()
    load = 0;
    tow = 0;
    public class Truck(String theOwner, String theBrand, int theBanger, double theLoad, int theTow)
    theOwner = super.theOwner();
    theBrand = super.theBrand();
    theBanger = super.theBanger();
    theLoad = super.theLoad();
    theTow = super.theTow();
    public void writeOutput()
    super.writeOuput();
    public void set(String aOwner, String aBrand, int aCylinder, double aLoad, int aTow)
    aOwner = super.aOwner();
    aBrand = super.aBrand();
    aCylinder = super.aCylinder();
    aLoad = super.aLoad();
    aTow = super.aTow();
    public class Vehicle{
    private String manufacturer;
    private int cylinder;
    private String owner;
    public Vehicle(){
    manufacturer = none;
    cylinder = 0;
    owner = 0;
    public class Vehicle(String theOwner, String theBrand, int theBanger)
    owner = theOwner;
    manufacturer = theBrand;
    cylinder = theBanger;
    public void writeOutput()
    super.writeOutput();
    System.out.println("Owner: = " + owner);
    System.out.println("Manufacturer: = " + manufacturer);
    System.out.println("Number of cylinders: = " + cylinder);
    public void set(String aOwner, String aBrand, int aCylinder, double aLoad, int aTow)
    aOwner = super.ownerName();
    aBrand = super.brandName();
    aCylinder = super.cylinder();
    aLoad = super.loadCapacity();
    aTow = super.towCapacity();
    }

        // *not* public class Vehicle
    public Vehicle(String theOwner, String theBrand, int theBanger)I think you mean this to be a constructor, not a class declaration.
    It's a good idea to wrap your code in code tags when you post. As
    Described here: http://forum.java.sun.com/help.jspa?sec=formatting
    Put [code] at the start of your code and [/code] at the end.
    [Edit] You have the same problem with the Truck class.

  • Why can't I get my program to compile?

    I'm very new to this, taking a class now, and I can't seem to get anything to work. I downloaded 1.4.1 and changed the path and so forth. At first, it didn't recognize javac, now it's saying it can't read the file on the disk. I have windows XP home edition and I just don't know what to do. I can't get ahold of my prof and I have an assignment to do. Any help will be worth a plate of chocolate chip cookies and a nice pat on the back. :D

    Wow, I wasn't expecting such a speedy reply...all of them.
    Let's see...I downloaded and tried to set up 1.4.1 and did just a simple Hello.java to see if everything worked. At first try, many hours ago, in the command prompt I typed it in and received a "javac is not recognized as an internal or external command operable program or batch file." Ok, I think I fixed that because at least it recognized it later. Then I recived an error message that read "cannot read file Hello.java, 1 error." I tried changing the path several times and even tried an autoexec file, which my prof said I didn't need to do because XP was beyond that. So, does that help clear anything up? I hope so.

  • Help T_T - Program not compiling properly

    I'm trying to add a short animation to the source file for a
    game that was built by an outside studio. Unfortunately, I can't
    seem to get the program to compile correctly: I get tons of errors,
    graphics dont diplay properly, etc. I thought perhaps I had just
    messed something up with my codes and animations, but even if i try
    to compile the original unedited file as a control test, i get the
    same problems. I have all the external files, scripts, etc.
    None of our scripters are in-house, so there's no one I can
    ask about this. I know just enough actionscript to prevent Flash
    from exploding into a gooey mass (which is how I ended up getting
    tasked with this), but basically my knowledge of flash is limited
    to it as an animation program so I'm not really sure if theres some
    kind of settings I need to change, specifically need to export as
    an .exe (shouldn't be, since the game runs as a .swf), or what.
    I know i'm not providing a whole lot of information about the
    problem, but thats because I'm not really sure what info is
    relevant. Let me know if there's anything people need from me and
    I'll get it to you.
    Thanks!

    Just a had brief look, but shouldn't it be:public class TempConversion extends JFrameIf you post code it is a good idea to use the formatting tags:
    http://forum.java.sun.com/help.jspa?sec=formatting
    Basically the idea is you put [code] at the start of your code and [/code]
    at the end.

  • I have a mac osx version 10.6.8 no windows and i am trying to install a program but keep getting can not run in dos mode  ( the disk says on back works on intel mac with parallels or vm fusion) is this program not compatible with my mac?

    i have a mac osx version 10.6.8 no windows installed and i am trying to install a program but keep getting can not run in dos mode  ( the disk says on back works on intel mac with parallels or vm fusion) is this program not compatible with my mac?

    You run Windows in Parallels or Fusion. Then in Windows you install the program.

  • I have made with iweb a website on my macbook, now i want to change it, through my imac, how can I get in the program , which is on the mac book. On both computer I have Lion

    i have made with iweb a website on my macbook, now i want to change it, through my imac, how can I get in the program , which is on the mac book. On both computer I have Lion

    You need to transfer your domain.sites file from your MacBook to your iMac.  This is the file where iWeb stores all info and can be found under User/Library/Application Support/iWeb/domain.sites.
    Transfer this file from your MacBook to the same place on your iMac and double click the domain.sites file and iWeb will open it on your iMac and you can update your site from there too.

  • I just purchased a MacBookPro after having a MacBook.  I have ILife, IWorks and Office for Mac.  How do I get those programs on to my MacBook Pro?  I will still use my MacBook at work so I need those programs to remain on it as well.

    I just purchased a MacBookPro after having a MacBook.  I have ILife, IWorks and Office for Mac.  How do I get those programs on to my MacBook Pro?  I will still use my MacBook at work so I need those programs to remain on it as well.

    You need a Firewire cable to run between the two Macs.  Using Utility>Migration Assistant running on your new MacBook Pro, transfer what you want (with all the preferences and such) from your MacBook to your MBP.  Here's more info from Apple.
    You might have an issue with the Serial number for Office, but hopefully you have that around.
    Hope this helps.

  • TS3649 my mac (2012) did not come with idvd.where can i get this program for download?

    My iMac os lion 10.7.2 (2012) did not come with idvd program. Where can I get this program for download?

    Hi
    If there is no iDVD on Your Mac (and it's not on newer Macs as Apple discarded it) then You need a program that can do this.
    Your Mac can burn CDs and DVDs - BUT DVD as Data-DVDs not as Video-DVDs - they need a program to be encoded and STRUCTURED as such.
    • iDVD is part of the boxed version of iLife'11 and can only be bought outside Apple as on Amazon and e-bay
    • DVD Studio pro - Part of FinalCut Studio Pro bundle - this to has expired and can only be bought second handed. (High price and tough learning Curve - but best ever done.)
    • Roxio Toast™ - Not as elegant as iDVD - but has many other positive additions (I like it as 10-Pro incl BD-component) (now version 11)
    • Burn - a free alternative I know of on internet. Very simple - Just for doing a plain Video-DVD
    Burn http://www.digital-digest.com/software/Burn.html
    • Free DVD Creator.app - free from Apple Store
    • FinalCut Pro-X which also can burn to DVD but without any nice themes.
    AppleMan1958
    You can also buy Compressor from Apple for $50 US. It will also create DVD and BluRay but without the nice themes.
    Yours Bengt W

  • IMovie'11 is programed to come with all macs. I just recently got mine fixed and it's not on there anymore. How do I get it back on my mac?

    iMovie'11 is programed to come with all macs. I just recently got mine fixed and it's not on there anymore. How do I get it back on my mac?

    KarenHimmel,
    iMovie ’11 is not programmed to come with all Macs — it didn’t come with my Mid 2010 MacBook Pro.
    Presuming that your Mac is newer than mine, have you checked to see if you can download iMovie ’11 gratis from the Mac App Store?

  • Getting one java program to compile another

    Was wondering if anyone knew if it is possible ot get one java program to compile another .java file and capture any errors.

    public static void RunCommand( String theCommand ) throws Exception
    Runtime runtime = Runtime.getRuntime();
    System.out.println( "Running Command " + theCommand ) ;
    Process process = runtime.exec(theCommand);
    String s = null ;
    BufferedReader stdInput = new BufferedReader(new InputStreamReader(process.getInputStream()));
    BufferedReader stdError = new BufferedReader(new InputStreamReader(process.getErrorStream()));
    // read the output from the command
    System.out.println("Here is the standard output of the command:\n");
    while ((s = stdInput.readLine()) != null) {
         System.out.println(s);
    // read any errors from the attempted command
    System.out.println("Here is the standard error of the command (if any):\n");
    while ((s = stdError.readLine()) != null) {
         System.out.println(s);

  • I am working on a windows based program thru Chrome on my Mac. It asked me to cont/alt/delete - how do I get the Mac to respond?

    I am working on a windows based program thru chrome on my mac - how do I control/alt/delete on the mac?

    Control key - Alt (also known as the Option key) and Delete key. However remember Chrome is not an Apple product so if that doesn't work you also might want to seek help on a Google forum that supports Chrome.

  • Just bought refurbished mac, and there's no GarageBand or iMovie and such. I got no disks with the laptop!! Is there any way to get these programs back?

    is there any way to get the programs back??!!??
    if not, are there any good free programs to replace these ones?

    I called Apple Customer Support (1- (800) 767-2775) to check on how much they charge for the gray restore disks that originally came with the MacBook and was quoted $16 dollars per disk plus S & H. Which would be $32 for the two disks. Just give them the serial number of your MacBook and they'll know which ones you need. With the original disks you also get the iLife that was current when your MacBook was bought included on the #2 disk.
    If you only want iPhoto or other single apps from iLife '11 you can get them from the App Store if you're upgraded to 10.6.8. iPhoto, iMovie or Garage Band for $15 each
    Or you can get an iLife DVD on eBay.  http://www.ebay.com/sch/i.html?_trkparms=72%253A1234%257C66%253A2%257C65%253A12% 257C39%253A1&_sacat=0&_sc=1&_nkw=apple%20ilife%2011&_sop=12

  • Java compiling on a mac

    Could Someone PLEASE explain with a good amount of detail how to compile a program through terminal on a mac. Whatever I try I can't get it to work.

    one might just say that one has no idea how to use
    the javac command in terminal at all, and one would
    just like a little bit of helpWhat have you tried to do? What terminal are you using? (I've never used a mac personally, but I understand they ship with a *NIX shell, right??)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • How do I get a program to start up when I turn my computer on?

    You know how in the dock, there's a little triangle under a program that's technically running even if you don't have a window open? Dashboard and Finder always have that triangle after start up. How do I get another program, like Safari to "start up" with that triangel all the time even if I don't want to have the browser window open when I turn my computer on?

    Open the Accounts pane of System Preferences, add it to the list of login items for your account, and check the box to hide it. Some applications, such as Mail, ignore the box in Mac OS X 10.4 and are always visible when launched; in this case, an AppleScript can be used to hide them.
    (24829)

Maybe you are looking for