Results 1 to 10 of 10

Thread: javac

  1. #1
    Sephij is offline Member
    Join Date
    Jul 2011
    Posts
    2
    Rep Power
    0

    Question javac

    I have done everything on "Hello World!" for Microsoft Windows (The Java™ Tutorials > Getting Started > The "Hello World!" Application)
    that page correctly, and as it said to. I installed the JDK correctly, and java -version
    works correctly. When I try to compile it the way that page says, I can't. What am I doing wrong? I saved it in C:\java
    I used cd C:\java


    Everything there is the same as mine, except the computer type, I use 7 instead of XP. And javac doesn't work. Please help. Need extra info, just tell me what.

  2. #2
    fakepics500 is offline Member
    Join Date
    Jul 2011
    Posts
    43
    Rep Power
    0

    Default

    if your are getiing javac not regonised as internal or extral command use this


    set the path
    got to my computer->properties->advanced->environment vairable->

    click new for user vairables for admistrator
    enter the name as:path
    address as: C:\Program Files\Java\jdk1.6.0\bin

  3. #3
    Sephij is offline Member
    Join Date
    Jul 2011
    Posts
    2
    Rep Power
    0

    Default

    Tried that, didn't work, moved the jdk to my java folder in plain C:, then updated variabl path. That didn't work. So I moved the javac in the bin folder to the java folder, tried that, it didn't work, and requsted jli.dll, so I moved that to. I then got this error:


    C:\Java>javac HelloWorldApp.java
    Exception in thread "main" java.lang.NoClassDefFoundError: com/sun/tools/javac/M
    ain
    Caused by: java.lang.ClassNotFoundException: com.sun.tools.javac.Main
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    Could not find the main class: com.sun.tools.javac.Main. Program will exit.

    C:\Java>





    I then tried to move everything in bin folder over, and got same error. What am I doing wrong?

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    You don't want to move things around like that, and if you have done so, you'll want to move them back. This is why you must post your full error message in your first post so we don't guess wrong as to the problem and its solution. Can you post your code and the exact file name?

  5. #5
    chipp's Avatar
    chipp is offline Member
    Join Date
    Jul 2011
    Posts
    62
    Rep Power
    0

    Default

    i have the same problem with you few days ago... go to my computer->properties->advanced->environment variable look for "path" and use ";" for add the address of your "bin" folder on java folder on program files. but btw, i'm using xp don't know if it works for you...

  6. #6
    Tolls is online now Moderator
    Join Date
    Apr 2009
    Posts
    12,090
    Rep Power
    20

    Default

    Quote Originally Posted by Sephij View Post
    When I try to compile it the way that page says, I can't.
    You should give the exact error message.

    Also I suspect (since you've moved your installation around) you might need to reinstall it...

  7. #7
    javalearner12 is offline Member
    Join Date
    Aug 2011
    Posts
    1
    Rep Power
    0

    Default javac configuring--easy

    Please find the steps as below:

    1. Create a temporary folder C:\mywork. Using Notepad or another text editor, create a small Java file HelloWorld.java with the following text:
    public class HelloWorld
    {
    public static void main(String[] args)
    {
    System.out.println("Hello, World!");
    }
    }
    Save your file as HelloWorld.java in C:\mywork. To make sure your file name is HeloWorld.java, (not HelloWorld.java.txt), first choose "Save as file type:" All files, then type in the file name HelloWorld.java.

    2. Run Command Prompt (found under All Programs/Accessories in the Start menu). Type
    C:\> cd \mywork
    This makes C:\mywork the current directory.
    C:\mywork> dir
    This displays the directory contents. You should see HelloWorld.java among the files.
    C:\mywork> set path=%path%;C:\Program Files\Java\jdk1.5.0_09\bin
    This tells the system where to find JDK programs.
    C:\mywork> javac HelloWorld.java
    This runs javac.exe, the compiler. You should see nothing but the next system prompt...
    C:\mywork> dir
    javac has created the HelloWorld.class file. You should see HelloWorld.java and HelloWorld.class among the files.
    C:\mywork> java HelloWorld
    This runs the Java interpreter. You should see the program output:
    Hello, World!
    If the system cannot find javac, check the set path command. If javac runs but you get errors, check your Java text. If the program compiles but you get an exception, check the spelling and capitalization in the file name and the class name and the java HelloWorld command. Java is case-sensitive!

    3.It is possible to make the path setting permanent but you have to be very careful because your system might crash if you make a mistake. Proceed with extreme caution!
    In Windows XP, go to Control Panel, choose "System," click on the "Advanced" tab, click on the "Environment variables" button. In the lower list, "System variables," click on Path:

    Click "Edit" and at the end append

    ;C:\Program Files\Java\jdk1.5.0_09\bin
    (or the path to the appropriate folder where the latest version of JDK is installed). Do not put spaces before the appended path string.

    Click OK on the path edit box and OK on the Ennvironment Variables box. The new setting will go into effect next time you run Command Prompt.

    i found it on some Java forum javamazon

  8. #8
    sunde887's Avatar
    sunde887 is offline Moderator
    Join Date
    Jan 2011
    Location
    Richmond, Virginia
    Posts
    3,069
    Blog Entries
    3
    Rep Power
    8

    Default

    Also make sure you aren't taking the exact directory link they are posting, instead find it and copy whatever yours is. Right click anything in the folder containing javac and click properties, then copy that dir and set it as your path variable. You may also have to reinstall, you should avoid moving the java stuff around unless you know what you are doing.

  9. #9
    joe98 is offline Member
    Join Date
    Mar 2011
    Posts
    16
    Rep Power
    0

    Default

    use cd java

  10. #10
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,798
    Rep Power
    7

    Default

    Quote Originally Posted by joe98 View Post
    use cd java
    For what? :confused:

Similar Threads

  1. need help with javac
    By pawanmutalik in forum New To Java
    Replies: 10
    Last Post: 02-03-2011, 06:56 AM
  2. javac
    By PhilArmstrong in forum New To Java
    Replies: 31
    Last Post: 11-21-2009, 03:46 PM
  3. javac?
    By sardare in forum Eclipse
    Replies: 1
    Last Post: 06-14-2008, 02:06 AM
  4. javac DOS
    By rdunne in forum New To Java
    Replies: 3
    Last Post: 01-01-2008, 11:49 AM
  5. Help with javaC
    By Daniel in forum New To Java
    Replies: 2
    Last Post: 07-04-2007, 02:44 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •