Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

New to JAVA, missing file

Options
  • 28-12-2005 11:40pm
    #1
    Moderators, Education Moderators, Motoring & Transport Moderators Posts: 7,395 Mod ✭✭✭✭


    I am going to start Java, but when I go to write something, no matter how simple, I always get an error message on compilation "Missing file - javac.exe". Anyone have any ideas where you can get this file??

    The program won't run without it


Comments

  • Registered Users Posts: 5,862 ✭✭✭RobAMerc


    you need to set up your paths properly.
    google paths java etc and you should find some explaination somewhere.
    java.sun.com also surely has an expliantion


  • Moderators, Education Moderators, Motoring & Transport Moderators Posts: 7,395 Mod ✭✭✭✭**Timbuk2**


    My paths are proper, I did a search of the computer and this file isn't coming up anywhere.

    Is there a SDK you have to download from sun.com for this to work and if there is is the Java 2 SE 1.4 one the right one, because I downloaded that one and it didn't fix the problem...


  • Registered Users Posts: 21,264 ✭✭✭✭Hobbes


    Did you download the JRE or the SDK? javac does not come with the JRE.

    Also check your paths again. javac should be in the bin directory of the java folder.


  • Closed Accounts Posts: 1,677 ✭✭✭Waltons


    There was some weird error I had when installing the JDK onto my laptop with XP. When setting the paths it refused to find javac.exe unless I placed a ";" after the path, even though there was nothing else referenced after. Not an issue on Windows 2000, but might be something to check if you're on XP


  • Moderators, Education Moderators, Motoring & Transport Moderators Posts: 7,395 Mod ✭✭✭✭**Timbuk2**


    I did check it there and it was but it still isn't working properly, I am not getting the same message, just some other funny one
    I get this printed to the text box
    java.lang.NoClassDefFoundError: com/sun/tools/javac/Main
    Exception in thread "main" 
    Tool completed with exit code 1
    

    What is the problem now

    BTW this is only a simple "Hello World" program


  • Advertisement
  • Registered Users Posts: 5,862 ✭✭✭RobAMerc


    Hobbes is right sounds like yuo got the JRE try type java at cmd prompt and then javac - if java doesn't crash and javac does thats it!

    Probably getting Java 1.5 is best, might as well start off with the newest version as there are some differences.


  • Registered Users Posts: 21,264 ✭✭✭✭Hobbes


    What is the problem now

    BTW this is only a simple "Hello World" program

    Welcome to the world of Java! :D You have met the first "Gotcha"

    Basically in order to run your application you have to have a method called...

    public static void main(String args[]) { 
    
    }
    

    This is a static method but you may or may not write the class as static so if you want access methods within this main part you will either need to declare them static as well, or create a class.

    eg.
    class MyClass {
       public static void main(String args[]) { 
          myMethod();  // This will run. 
          // myOtherMethod();  // This will not work.
    
          MyClass c = new MyClass(); 
          c.myOtherMethod();
          // c.myMethod();     // You should never do this. 
                                      //Should cause a compiler warning?
       }
    
       // This is a static method so you can call it from the class directly.
       public static myMethod() {
          System.out.println("Hello World1");
       }
    
       // This is a non static method so 
       //  you need to create an object before you can access.
       public myOtherMethod() {
           System.out.println("Hello World1");
       }
     
    }
    

    Also a thing to watch out is that the java.exe might not see your class. Ensure you have..

    SET CLASSPATH=%CLASSPATH%;.


  • Registered Users Posts: 9,481 ✭✭✭projectmayhem


    try going to my computer > properties > advanced > environment variables

    in here you should see "PATH C:\j2sdk\bin..."
    and in the bottom box: "CLASSPATH C:\whatever"

    if not try doing this:

    click "new" under the top box. Var Name: CLASSPATH
    Var Value: .


  • Registered Users Posts: 20,916 ✭✭✭✭Stark


    You have a corrupt installation of Java by the sounds of it. javac doesn't need CLASSPATH set to run, it's automatically setup to find its own classes by default

    The error:
    java.lang.NoClassDefFoundError: com/sun/tools/javac/Main
    Exception in thread "main" 
    Tool completed with exit code 1
    

    is normally due to a missing tools.jar , ie: you probably have a corrupt installation.

    Try completely removing your current version of Java (Control Panel->Add/Remove programs), then download and install the Java 5 SDK and try again.

    ⛥ ̸̱̼̞͛̀̓̈́͘#C̶̼̭͕̎̿͝R̶̦̮̜̃̓͌O̶̬͙̓͝W̸̜̥͈̐̾͐Ṋ̵̲͔̫̽̎̚͠ͅT̸͓͒͐H̵͔͠È̶̖̳̘͍͓̂W̴̢̋̈͒͛̋I̶͕͑͠T̵̻͈̜͂̇Č̵̤̟̑̾̂̽H̸̰̺̏̓ ̴̜̗̝̱̹͛́̊̒͝⛥



  • Registered Users Posts: 2,835 ✭✭✭StickyMcGinty


    this will do it all for ye, class paths and all!!

    http://stevenotroney.com/java/setup.exe


  • Advertisement
Advertisement