Page 1 of 2 12 LastLast
Results 1 to 20 of 23
  1. #1
    gatehrdy is offline Member
    Join Date
    Aug 2010
    Location
    I live in Arizona
    Posts
    13
    Rep Power
    0

    Default dos compiling error msg.

    I am trying to understand how to compile programs from the command prompt. What needs to be in place to do this. I have made a temp. file called c:mywork and found the directory from the dos prompt, then typed javac FirstApplet.java and I get an error. Please help. :confused:

  2. #2
    Lil_Aziz1's Avatar
    Lil_Aziz1 is offline Senior Member
    Join Date
    Dec 2009
    Location
    United States
    Posts
    343
    Rep Power
    5

    Default

    What was the error? Copy & paste it. Do not crop it.
    "Experience is what you get when you don't get what you want" (Dan Stanford)
    "Rise and rise again until lambs become lions" (Robin Hood)

  3. #3
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    19

  4. #4
    gatehrdy is offline Member
    Join Date
    Aug 2010
    Location
    I live in Arizona
    Posts
    13
    Rep Power
    0

    Default

    "javac is not recognized as an internal or external command, operable program or batch file." This is the error msg after I get into the C:\mywork file> and type javac FirstApplet.java

  5. #5
    curmudgeon is offline Senior Member
    Join Date
    May 2010
    Posts
    436
    Rep Power
    5

    Default

    This is a problem with your not having set the system's path correctly. Have you gone through the Sun/Oracle getting started tutorials? Right away, they'll tell you how to set your system's path so that you won't get this error.

  6. #6
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    19

  7. #7
    gatehrdy is offline Member
    Join Date
    Aug 2010
    Location
    I live in Arizona
    Posts
    13
    Rep Power
    0

    Default

    ok, thanks for the tip. I'll keep looking around.
    John 15:7 "If ye abide in me, and my words abide in you, ye shall ask what ye will, and it shall be done unto you.":)

  8. #8
    gatehrdy is offline Member
    Join Date
    Aug 2010
    Location
    I live in Arizona
    Posts
    13
    Rep Power
    0

    Default Here it Goes

    At the c:Program Files(x86)\java\jdk1.6.0_21\bin> I typed java c:\mywork (which is where the HelloWorld.java file is, and it spit this back out at me:

    Exception in thread "main" java.lang.NoClassDefFoundError:C:\mywork
    caused by:java.lang.ClassNotFoundException:C:\mywork

    at java.netURLClassLoader$1.run(URLClassLoader.java:2 02)
    at java.security.AccessControler.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.j ava.190
    at java.Lang.ClassLoader.loadClass (ClassLoader.java:307)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launche r.java:301)
    at java.Lang.ClassLoader.LoadClass(ClassLoader.java:2 48)
    could not find the main class:c:\mywork.Program will exit

    I am just trying to run this simple program, and this is it exactly as it is saved in notepad in c:mywork\HelloWorld.java

    What do I need to do to compile and run this program from dos please?:)
    John 15:7 "If ye abide in me, and my words abide in you, ye shall ask what ye will, and it shall be done unto you.":)

  9. #9
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,188
    Rep Power
    19

    Default

    If you had gone through the tutorial recommended by curmudgeon, you would have known exactly what's wrong. Also, you wouldn't be kludging around trying to run programs from the jdk/bin directory.

    The Java™ Tutorials

    db

  10. #10
    siva_vs_siva is offline Member
    Join Date
    Aug 2010
    Posts
    31
    Rep Power
    0

    Default

    Running process..

    1. go to your location using CD cmd.(ex cd c:\mywork\).
    2. set path (set path=c:C:\Program Files\Java\jdk1.6.0_18\bin).
    3. now compile your programs.

  11. #11
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,188
    Rep Power
    19

    Default

    That's not going to help as long as the OP does this
    I typed java c:\mywork (which is where the HelloWorld.java file is
    db

  12. #12
    gatehrdy is offline Member
    Join Date
    Aug 2010
    Location
    I live in Arizona
    Posts
    13
    Rep Power
    0

    Default

    Siva vs Siva thank you for trying, but it still won't work. AND Darryl I have read and tried to set paths via the instructions I have read, but nothing works. I appreciate your help. Thanks.
    John 15:7 "If ye abide in me, and my words abide in you, ye shall ask what ye will, and it shall be done unto you.":)

  13. #13
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,272
    Rep Power
    25

    Default

    Try this:
    open a command prompt window and change to the folder holding the .java file. You change folders by using the cd command.
    Show your OS's path setting by entering the PATH command. For example:
    D:\JavaDevelopment\NormsDev>path
    PATH=C:\Program Files\PHP\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDO WS\System32\Wbem;C:\Program Files\Java\jdk1.5.0_04\bin;C:\BatchFiles;C:\Progra m Files\Support Tools\;C:\WINDOWS\sy
    stem32\WindowsPowerShell\v1.0;C:\Program Files\QuickTime\QTSystem\

    D:\JavaDevelopment\NormsDev>
    When you can see the .java file by using a dir command, issue the javac command with the fullname of the .java file. For example:
    javac HelloWorld.java

    If there are any errors, copy and paste them here.
    To copy the contents of the command prompt window:
    Click on Icon in upper left corner
    Select Edit
    Select 'Select All' - The selection will show
    Click in upper left again
    Select Edit and click 'Copy'

    Paste here.

  14. #14
    gatehrdy is offline Member
    Join Date
    Aug 2010
    Location
    I live in Arizona
    Posts
    13
    Rep Power
    0

    Default ?

    Microsoft Windows [Version 6.1.7600]
    Copyright (c) 2009 Microsoft Corporation. All rights reserved.


    Directory of C:\

    08/27/2010 02:12 PM <DIR> BlueJ
    08/29/2010 12:40 PM 3,304 bootsqm.dat
    08/30/2010 11:43 PM <DIR> mywork
    08/16/2010 05:31 PM <DIR> Program Files
    08/30/2010 11:19 AM <DIR> Program Files (x86)
    08/29/2010 08:50 PM <DIR> Python27
    08/16/2010 04:22 PM <DIR> Users
    08/27/2010 10:15 PM <DIR> Windows
    1 File(s) 3,304 bytes
    7 Dir(s) 210,718,994,432 bytes free

    C:\>cd mywork

    C:\mywork>javac HelloWorld.java
    'javac' is not recognized as an internal or external command,
    operable program or batch file.

    C:\mywork>dir
    Volume in drive C is TI105846W0F
    Volume Serial Number is 4475-038A

    Directory of C:\mywork

    08/30/2010 11:43 PM <DIR> .
    08/30/2010 11:43 PM <DIR> ..
    08/29/2010 11:36 PM 440 FirstApplet.java
    08/30/2010 11:43 PM 426 HelloWorld.class
    08/30/2010 11:24 PM 146 HelloWorld.java
    3 File(s) 1,012 bytes
    2 Dir(s) 210,718,470,144 bytes free

    C:\mywork>java HelloWorld.java
    'java' is not recognized as an internal or external command,
    operable program or batch file.

    C:\mywork>path
    PATH=C:\windows\system32;C:\windows;C:\windows\Sys tem32\Wbem;C:\windows\System32\WindowsPowerShell\v 1.0\;C:\Program Files (x86)\ATI Technologies\ATI.ACE\Core-Static

    C:\mywork>

    Thank you for helping on my level. Here is the result.
    John 15:7 "If ye abide in me, and my words abide in you, ye shall ask what ye will, and it shall be done unto you.":)

  15. #15
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,272
    Rep Power
    25

    Default

    You need to add the path to the folder with the javac.exe file to your OS's Environment variable: PATH
    Look at my post of the value of the PATH variable. Here are the steps for WinXP:
    The PATH environment variable is set from the Settings | Control Panel | System panel.
    Select the Advanced tab and
    Click on the Environment variable's button.
    At the bottom in System Variables, find the PATH entry and click the Edit button
    Add the new path using ; to separate it
    Its a stupid small text field so be careful.

    Once the PATH variable has the path to your javac.exe, the OS can find it and the compile should work.

  16. #16
    gatehrdy is offline Member
    Join Date
    Aug 2010
    Location
    I live in Arizona
    Posts
    13
    Rep Power
    0

    Default windows 7

    Thank you again. Are the instructions the same for win7?
    John 15:7 "If ye abide in me, and my words abide in you, ye shall ask what ye will, and it shall be done unto you.":)

  17. #17
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,272
    Rep Power
    25

    Default

    Sorry, I have yet to work on Win7

  18. #18
    gatehrdy is offline Member
    Join Date
    Aug 2010
    Location
    I live in Arizona
    Posts
    13
    Rep Power
    0

    Default

    no prob. I went in and found the place to set the path, edited it as you said to, and it still doesn't work, so I will have to get someone to look at it first hand and help me. Thank you for your time.
    John 15:7 "If ye abide in me, and my words abide in you, ye shall ask what ye will, and it shall be done unto you.":)

  19. #19
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,272
    Rep Power
    25

    Default

    it still doesn't work,
    Can you open a command prompt, enter: PATH, copy and paste the contents of the screen here?
    There are many ways to "not work"? The previous one was that the OS didn't find the command you were using. If you have set the path properly, then the OS can find the command. Then next error would be from the command itself.

  20. #20
    gatehrdy is offline Member
    Join Date
    Aug 2010
    Location
    I live in Arizona
    Posts
    13
    Rep Power
    0

    Default trials

    Microsoft Windows [Version 6.1.7600]
    Copyright (c) 2009 Microsoft Corporation. All rights reserved.

    C:\Users\Ramblerkat>cd\

    C:\>cd Program Files (x86)

    C:\Program Files (x86)>cd java

    C:\Program Files (x86)\Java>dir
    Volume in drive C is TI105846W0F
    Volume Serial Number is 4475-038A

    Directory of C:\Program Files (x86)\Java

    08/26/2010 03:48 PM <DIR> .
    08/26/2010 03:48 PM <DIR> ..
    08/26/2010 03:49 PM <DIR> jdk1.6.0_21
    08/26/2010 03:49 PM <DIR> jre6
    0 File(s) 0 bytes
    4 Dir(s) 210,712,719,360 bytes free

    C:\Program Files (x86)\Java>cd jdk1.6.0_21

    C:\Program Files (x86)\Java\jdk1.6.0_21>cd bin

    C:\Program Files (x86)\Java\jdk1.6.0_21\bin>path
    PATH=C:\windows\system32;C:\windows;C:\windows\Sys tem32\Wbem;C:\windows\System32\WindowsPowerShell\v 1.0\;C:\Program Files (x86)\ATI Technologies\ATI.ACE\Core-Static;c:\Program File
    s (x86)\java\jdk1.6.0_21\bin

    C:\Program Files (x86)\Java\jdk1.6.0_21\bin>javac HelloWorld.java
    javac: file not found: HelloWorld.java
    Usage: javac <options> <source files>
    use -help for a list of possible options

    C:\Program Files (x86)\Java\jdk1.6.0_21\bin>cd\

    C:\>cd mywork

    C:\mywork>dir
    Volume in drive C is TI105846W0F
    Volume Serial Number is 4475-038A

    Directory of C:\mywork

    08/31/2010 02:53 PM <DIR> .
    08/31/2010 02:53 PM <DIR> ..
    08/31/2010 02:53 PM 783 DrawingLines.class
    08/31/2010 02:53 PM 440 DrawingLines.java
    08/29/2010 11:36 PM 440 FirstApplet.java
    08/31/2010 02:50 PM 426 HelloWorld.class
    08/30/2010 11:24 PM 146 HelloWorld.java
    5 File(s) 2,235 bytes
    2 Dir(s) 210,712,715,264 bytes free

    C:\mywork>javac DrawingLines.java

    C:\mywork>javac HelloWorld.java

    C:\mywork>javac FirstApplet.java
    FirstApplet.java:4: class DrawingLines is public, should be declared in a file named DrawingLines.java
    public class DrawingLines extends Applet {
    ^
    1 error

    C:\mywork>cd\

    C:\>path
    PATH=C:\windows\system32;C:\windows;C:\windows\Sys tem32\Wbem;C:\windows\System32\WindowsPowerShell\v 1.0\;C:\Program Files (x86)\ATI Technologies\ATI.ACE\Core-Static;c:\Program File
    s (x86)\java\jdk1.6.0_21\bin

    C:\>
    John 15:7 "If ye abide in me, and my words abide in you, ye shall ask what ye will, and it shall be done unto you.":)

Page 1 of 2 12 LastLast

Similar Threads

  1. Java compiling error
    By fadijava in forum New To Java
    Replies: 21
    Last Post: 10-15-2009, 08:55 AM
  2. Having error while compiling
    By Kodeee in forum New To Java
    Replies: 12
    Last Post: 03-17-2009, 11:08 AM
  3. Compiling error
    By lawksalih in forum New To Java
    Replies: 6
    Last Post: 01-29-2008, 07:26 PM
  4. Error during compiling
    By boy22 in forum New To Java
    Replies: 2
    Last Post: 08-03-2007, 02:42 AM
  5. Error while compiling
    By ai_2007 in forum Advanced Java
    Replies: 1
    Last Post: 07-01-2007, 11:37 AM

Posting Permissions

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