Page 1 of 2 12 LastLast
Results 1 to 20 of 23
  1. #1
    Panthereitor is offline Member
    Join Date
    May 2011
    Posts
    10
    Rep Power
    0

    Exclamation Common error in benigner

    Hello I got "Could not find the main class: Program will be exit.

    D:\Instalacion Java TM>java HelloWorldApp.java
    Exception in thread "main" java.lang.NoClassDefFoundError: HelloWorldApp/java
    Caused by: java.lang.ClassNotFoundException: HelloWorldApp.java
    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: HelloWorldApp.java. Program will exit.

    D:\Instalacion Java TM>


    and here note pad file:


    /**
    * The HelloWorldApp class implements an application that
    * simply displays "Hello World!" to the standard output.
    */
    class HelloWorldApp {
    public static void main(String[] args) {
    // Display "Hello World!"
    System.out.println("Hello World!");
    }
    }


    Where is my common error?
    Thanks.
    Last edited by Panthereitor; 05-31-2011 at 10:18 PM.

  2. #2
    milovan is offline Senior Member
    Join Date
    Jan 2011
    Location
    Belgrade, Serbia
    Posts
    292
    Rep Power
    4

    Default

    try
    Java Code:
    D:\Instalacion Java TM>javac HelloWorldApp.java
    and after

    Java Code:
    D:\Instalacion Java TM>java HelloWorldApp
    of course if your enviroment is set properly

  3. #3
    Panthereitor is offline Member
    Join Date
    May 2011
    Posts
    10
    Rep Power
    0

    Default

    Both code answer it:

    D:\Instalacion Java TM>D:\Instalacion Java TM>java HelloWorldApp.java
    "D:\Instalacion" no se reconoce como un comando interno o externo,
    programa o archivo por lotes ejecutable

  4. #4
    Panthereitor is offline Member
    Join Date
    May 2011
    Posts
    10
    Rep Power
    0

    Default

    English translate

    D: \ Install Java TM> D: \ Install Java TM> java HelloWorldApp.java
    "D: \ Install" is not recognized as an internal or external command,
    program or batch file

  5. #5
    milovan is offline Senior Member
    Join Date
    Jan 2011
    Location
    Belgrade, Serbia
    Posts
    292
    Rep Power
    4

    Default

    ok, sorry, I see now you are realy new

    First you complie your code with the next line:

    Java Code:
    javac HelloWorldApp.java

    And then you execute your code with the next line:

    Java Code:
    java HelloWorldApp
    Please try and let me know if it works.

    Milovan

  6. #6
    milovan is offline Senior Member
    Join Date
    Jan 2011
    Location
    Belgrade, Serbia
    Posts
    292
    Rep Power
    4

    Default

    And to be more clear to you

    Java Code:
    D: \ Install Java TM>
    referes to your current location, it is always on screen, you just type commands like javac something.java.

  7. #7
    Panthereitor is offline Member
    Join Date
    May 2011
    Posts
    10
    Rep Power
    0

    Default

    well I am sorry but this is the first time for me.

    In wich line should I have write the code? i mean

    D:\Instalacion Java TM>javac HelloWorldApp.java or javac HelloWorldApp.java

  8. #8
    milovan is offline Senior Member
    Join Date
    Jan 2011
    Location
    Belgrade, Serbia
    Posts
    292
    Rep Power
    4

    Default

    Well, I guess that you have your command prompt D:\Instalacion Java TM> right now on the screen and your blinking cursor is right after. So just type javac HelloWorldApp.java
    and press enter.

  9. #9
    Panthereitor is offline Member
    Join Date
    May 2011
    Posts
    10
    Rep Power
    0

    Default

    Does not works too

    It said "javac" is not recognized as an internal or external command,
    program or batch file

    And does not works with others too it said same as above. It takes fisrt word and put between " " and displays same as above.
    Thanks
    Last edited by Panthereitor; 05-31-2011 at 10:25 PM.

  10. #10
    milovan is offline Senior Member
    Join Date
    Jan 2011
    Location
    Belgrade, Serbia
    Posts
    292
    Rep Power
    4

    Default

    ok, let's check something. I want you to type java and to press enter, then tell me what hapens.

  11. #11
    Panthereitor is offline Member
    Join Date
    May 2011
    Posts
    10
    Rep Power
    0

    Default

    Here is:


    Microsoft Windows XP [Versión 5.1.2600]
    (C) Copyright 1985-2001 Microsoft Corp.

    C:\Documents and Settings\ˇ-..JuanDavid..-ˇ>java
    Usage: java [-options] class [args...]
    (to execute a class)
    or java [-options] -jar jarfile [args...]
    (to execute a jar file)

    where options include:
    -client to select the "client" VM
    -server to select the "server" VM
    -hotspot is a synonym for the "client" VM [deprecated]
    The default VM is client.

    -cp <class search path of directories and zip/jar files>
    -classpath <class search path of directories and zip/jar files>
    A ; separated list of directories, JAR archives,
    and ZIP archives to search for class files.
    -D<name>=<value>
    set a system property
    -verbose[:class|gc|jni]
    enable verbose output
    -version print product version and exit
    -version:<value>
    require the specified version to run
    -showversion print product version and continue
    -jre-restrict-search | -jre-no-restrict-search
    include/exclude user private JREs in the version search
    -? -help print this help message
    -X print help on non-standard options
    -ea[:<packagename>...|:<classname>]
    -enableassertions[:<packagename>...|:<classname>]
    enable assertions
    -da[:<packagename>...|:<classname>]
    -disableassertions[:<packagename>...|:<classname>]
    disable assertions
    -esa | -enablesystemassertions
    enable system assertions
    -dsa | -disablesystemassertions
    disable system assertions
    -agentlib:<libname>[=<options>]
    load native agent library <libname>, e.g. -agentlib:hprof
    see also, -agentlib:jdwp=help and -agentlib:hprof=help
    -agentpath:<pathname>[=<options>]
    load native agent library by full pathname
    -javaagent:<jarpath>[=<options>]
    load Java programming language agent, see java.lang.instrument

    -splash:<imagepath>
    show splash screen with specified image

    C:\Documents and Settings\ˇ-..JuanDavid..-ˇ>

  12. #12
    milovan is offline Senior Member
    Join Date
    Jan 2011
    Location
    Belgrade, Serbia
    Posts
    292
    Rep Power
    4

    Default

    Ok then your java enviroment is set properly. I guess you have your java file named HelloWorldApp.java located somewhere.
    Open command prompt and navigate to that location. When there, type javac HelloWorldApp.java and if there is an error please post it here again.

  13. #13
    Panthereitor is offline Member
    Join Date
    May 2011
    Posts
    10
    Rep Power
    0

    Default

    Diplays that javac doesn't exist.

    I installed java in: D:\Instalacion Java TM.
    For info I have windows xp in spanish laguage.
    This is the error:
    D:\Instalacion Java TM>javac HelloWorldApp.java
    "javac" no se reconoce como un comando interno o externo,
    programa o archivo por lotes ejecutable.

    PD: Only with command java HelloWorldApp.java
    Displays: Could not find the main class: HelloWorldApp.java. Program will exit.
    Last edited by Panthereitor; 05-31-2011 at 11:14 PM.

  14. #14
    milovan is offline Senior Member
    Join Date
    Jan 2011
    Location
    Belgrade, Serbia
    Posts
    292
    Rep Power
    4

    Default

    so we must check again your jdk. please open cmd prompt, navigate to C disc (type C: and press enter) and then type next line:

    Java Code:
    javac -version
    it should give you back current version of instaled JDK. post it here...

  15. #15
    Panthereitor is offline Member
    Join Date
    May 2011
    Posts
    10
    Rep Power
    0

    Default

    Same error, maybe I havenot SDK.

    C:\>javac -version
    "javac" no se reconoce como un comando interno o externo,
    programa o archivo por lotes ejecutable.

    It is like the file extension was chaged or not exist.
    Last edited by Panthereitor; 05-31-2011 at 11:30 PM.

  16. #16
    milovan is offline Senior Member
    Join Date
    Jan 2011
    Location
    Belgrade, Serbia
    Posts
    292
    Rep Power
    4

    Default

    JDK (or SDK) is usualiy installed in next location C:\Program Files\Java\jdk1.6.0_??, try to find it. if not, go to Java SE Downloads and download it. After install it should work fine and try again to run commands like in post #5. just make sure to do it from folder where your HelloWorldApp.java is located.

  17. #17
    Panthereitor is offline Member
    Join Date
    May 2011
    Posts
    10
    Rep Power
    0

    Default

    I found it but I write java -version not javac -version
    here is version:

    C:\>java -version
    java version "1.6.0_25"
    java(TM) SE Runtime Environment (1.6.0_25-b06)
    java Hotspot (TM) Client VM (build 20.0-b11, mixed mode, sharing)
    C:\>

  18. #18
    milovan is offline Senior Member
    Join Date
    Jan 2011
    Location
    Belgrade, Serbia
    Posts
    292
    Rep Power
    4

    Default

    yes it means you have installed JRE (Java Runtime Environment) and probably not JDK (Java Development Kit).
    Last edited by milovan; 05-31-2011 at 11:51 PM.

  19. #19
    Panthereitor is offline Member
    Join Date
    May 2011
    Posts
    10
    Rep Power
    0

    Default

    Where can I download JDK'?

    and JRE does not enough? why I need JDK.

    Thanks.
    Last edited by Panthereitor; 05-31-2011 at 11:53 PM.

  20. #20
    milovan is offline Senior Member
    Join Date
    Jan 2011
    Location
    Belgrade, Serbia
    Posts
    292
    Rep Power
    4

    Default

    I gave you link in post #16 just click. JRE is for running java programs, it doesn't have javac (java compiler) to compile .java files. So you can execute but not create java programs with JRE

Page 1 of 2 12 LastLast

Similar Threads

  1. common components for game
    By temyong in forum Advanced Java
    Replies: 1
    Last Post: 03-15-2011, 04:03 AM
  2. Help to debug a common error please!
    By TaxpayersMoney in forum New To Java
    Replies: 4
    Last Post: 05-08-2010, 03:31 PM
  3. ow to get Home directory using Common Net ftp api?
    By cprash.aggarwal in forum Advanced Java
    Replies: 1
    Last Post: 03-01-2009, 05:57 PM
  4. How to get Home directory using Common Net ftp api?
    By cprash.aggarwal in forum Networking
    Replies: 1
    Last Post: 03-01-2009, 05:37 PM
  5. Common error page using struts tiles...?
    By prabhurangan in forum Web Frameworks
    Replies: 0
    Last Post: 08-28-2008, 02:34 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
  •