Javac??


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 6 of 6

Thread: Javac??

  1. #1
    Join Date
    Jun 2004
    Posts
    5

    Javac??

    I need help on where to download javac. I'm reading a book on java and it doesnt say where to download it.
    Just another noob.

  2. #2
    Join Date
    Sep 2002
    Posts
    124
    Hi, Jnh543

    To program in Java you'll need the SDK , or Software Developer's Kit. This includes the all important Java Compiler, or javac. You can get it from the following link...


    http://java.sun.com/j2se/1.4.2/download.html


    And I'd try downloading and installing the SDK under the hading saying J2SE v 1.4.2_04 SDK

    Hope it helps,
    JM

  3. #3
    Join Date
    Jun 2004
    Posts
    5
    I tried to download it several times but every time i get to a certain part of the download it just stops. I've tried waiting, I waited for a very long time, but I'm pretty sure its stuck.
    Just another noob.

  4. #4
    Join Date
    Jun 2004
    Posts
    5
    Ok, I downloaded it but theres still a problem... I now have a bunch of files and stuff called "ben" "demo" "jre" "lib" "include-old" "include" and "src" where I downloaded it to. I can't find the compiler though. What do I do?
    Just another noob.

  5. #5
    Join Date
    Sep 2002
    Posts
    124
    Hello again.
    You're just about there !
    All you need to do is write some code in whichever text editor you want. Then you need to save it with the file extension .java
    eg, you have written a program called HelloWorld you save it as HelloWorld.java
    To compile the program, you open up a command prompt ( or shell if you're running Linux ) and type

    javac HelloWorld.java

    and press ENTER. The program should now compile. To run the program, you type

    java HelloWorld

    and press ENTER

    A FEW POINTS...
    I usually save .java files in the BIN folder ( you'll find it in the stuff you've just downloaded and installed.) To run the javac compiler command, change directory to the location of the BIN file, eg, in Windows, from the root of C:

    cd j2sdk1.4.2\bin

    I have to admit, I'm a bit lazy, so I like using an IDE which not only indents code, but also has a handy COMPILE and RUN button. eg JCreator

    http://www.jcreator.com/

    Hope this helps.
    JM

  6. #6
    Join Date
    Jul 2004
    Posts
    40
    Just a few suggestions:
    If you have installed the JSDK properly, you shouldn´t have to change to the bin directory to compile as it should have set your PATH variable to point to the bin directory, where the javac.exe and java.exe files are.
    You can check this by just typing java on the command prompt and you should get a hint that you have left out parameters, if you get something like: "application or file not found", then you need to change your PATH variable.
    Very important is also your CLASSPATH variable which is where java looks for your .class files when you run a java application. You should also add ./; to this which will include the directory you are currently in. You can do this by just adding "CLASSPATH=%CLASSPATH%;./;" in your autoexec.bat file.
    Now you should be able to compile and run from the same directory where your .java files are.

    just type: javac Myfile.java
    now when there are no errors, you get a Myfile.class file in the same directory.
    now type: java Myfile
    now the .class file will be run.

    Last suggestion: You can try JOE to start off with java, it will automatically find your java installation and include it in the program you you can compile and run with the push of a button.

    Good luck
    Hope this helps.
    I think, therefore I am....... I think.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center