Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 13 of 13

Thread: helloworld noob

  1. #1
    Junior Member
    Join Date
    Jul 2010
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhappy helloworld noob

    Hello I'm new to the forum and to java. I'm working on having my hello world app run in windows but I'm getting errors in the cmd and I'm not sure what it means.

    I type javac helloworldapp.java and i recieve the following that i will post as an attachment. Any help will mean a lot thank you!

    And here is the code just in case

    package helloworldapp;
     
    **
     *
     * @author Dan
     */
    public class HelloWorldApp {
     
        /**
         * @param args the command line arguments
         */
        public static void main(String[] args) {
            System.out.println("Hello World!"); // Display the string.
        }
     
    }
    Attached Images Attached Images
    Last edited by LostFury2012; July 5th, 2010 at 01:02 PM.


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,139
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: helloworld noob

    that's weird. No idea how you get that error.
    Could be a bad JDK install. Can you go to a command prompt and enter: Set
    to display your environment variables. Then copy the contents of the screen here:
    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.

    Where is the javac.exe command located?

  3. #3
    Junior Member
    Join Date
    Jul 2010
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: helloworld noob

    Microsoft Windows [Version 6.0.6002]
    Copyright (c) 2006 Microsoft Corporation. All rights reserved.

    C:\Users\Dan>set
    ALLUSERSPROFILE=C:\ProgramData
    APPDATA=C:\Users\Dan\AppData\Roaming
    CLASSPATH=.;C:\Program Files (x86)\Java\jre6\lib\ext\QTJava.zip
    CommonProgramFiles=C:\Program Files\Common Files
    CommonProgramFiles(x86)=C:\Program Files (x86)\Common Files
    COMPUTERNAME=DAN-PC
    ComSpec=C:\Windows\system32\cmd.exe
    DFSTRACINGON=FALSE
    FP_NO_HOST_CHECK=NO
    HOMEDRIVE=C:
    HOMEPATH=\Users\Dan
    LOCALAPPDATA=C:\Users\Dan\AppData\Local
    LOGONSERVER=\\DAN-PC
    NUMBER_OF_PROCESSORS=4
    OS=Windows_NT
    Path=c:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Windows\system32;
    C:\Windows;C:\Windows\System32\Wbem;C:\Program Files (x86)\Autodesk\Backburner\;
    C:\Program Files (x86)\Common Files\Autodesk Shared\;C:\Program Files (x86)\Quic
    kTime\QTSystem\
    PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WS F;.WSH;.MSC
    PROCESSOR_ARCHITECTURE=AMD64
    PROCESSOR_IDENTIFIER=Intel64 Family 6 Model 23 Stepping 7, GenuineIntel
    PROCESSOR_LEVEL=6
    PROCESSOR_REVISION=1707
    ProgramData=C:\ProgramData
    ProgramFiles=C:\Program Files
    ProgramFiles(x86)=C:\Program Files (x86)
    PROMPT=$P$G
    PUBLIC=C:\Users\Public
    QTJAVA=C:\Program Files (x86)\Java\jre6\lib\ext\QTJava.zip
    SESSIONNAME=Console
    sourcesdk=c:\program files (x86)\steam\steamapps\y2j101\sourcesdk
    SystemDrive=C:
    SystemRoot=C:\Windows
    TEMP=C:\Users\Dan\AppData\Local\Temp
    TMP=C:\Users\Dan\AppData\Local\Temp
    TRACE_FORMAT_SEARCH_PATH=\\NTREL202.ntdev.corp.mic rosoft.com\34FB5F65-FFEB-4B61-
    BF0E-A6A76C450FAA\TraceFormat
    USERDOMAIN=Dan-PC
    USERNAME=Dan
    USERPROFILE=C:\Users\Dan
    VProject=c:\program files (x86)\steam\steamapps\SourceMods\mymod
    VS100COMNTOOLS=C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\Tools
    \
    windir=C:\Windows

    C:\Users\Dan>

    Well at first the javac command was not recgonized. the path was C:\Program Files (x86)\Java\jdk1.6.0_20\bin

    so i copied all the .exe from the folder and pasted them in my system32 folder and then thats when i got that error

    thanks for replying!

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,139
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: helloworld noob

    The javac.exec command probably expects to be in a folder with all the parts it needs.
    Delete the one you copied to the system32 folder and add an entry to the PATH environment variable that ends in the jdk's bin folder.
    Here's what my PATH variable has:
    Microsoft Windows XP [Version 5.1.2600]
    (C) Copyright 1985-2001 Microsoft Corp.

    D:\Norms\Norms Tools>path
    PATH=C:\Program Files\PHP\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDO WS\System32\Wb
    em;C:\Program Files\Java\jdk1.5.0_04\bin;C:\BatchFiles;C:\Program Files\Support
    Tools\;C:\WINDOWS\system32\WindowsPowerShell\v1.0; C:\Program Files\QuickTime\QTS
    ystem\

    D:\Norms\Norms Tools>

  5. #5
    Super Moderator helloworld922's Avatar
    Join Date
    Jun 2009
    Posts
    2,895
    Thanks
    23
    Thanked 619 Times in 561 Posts
    Blog Entries
    18

    Default Re: helloworld noob

    It's because of the package declaration.

    You must put the class into the a folder named helloworldapp, or you can remove the package declaration.

  6. #6
    Junior Member
    Join Date
    Jul 2010
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: helloworld noob

    sorry how do i set the path, I'm just a bit confused cause i don't completely understand why its not working so when i try to do something I'm kinda doing it blindly if you know what i mean. btw i copied everything from the bin folder to system32

    helloworld922 i tried removing the package declaration and still have the same error
    Last edited by LostFury2012; July 5th, 2010 at 03:39 PM.

  7. #7
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,139
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: helloworld noob

    The PATH environment variable is set from the Settings | Control Panel | System panel.
    Select the Advanced tab and Click on the Environment variables button.
    At the bottom in System Variables, find the PATH entry and click the Edit button
    Its a stupid small text field so be careful.

    btw i copied everything from the bin folder to system32
    That is NOT the way to do it. Don't mix app code with system code like that. Sure way for a disaster.

  8. #8
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,139
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: helloworld noob

    You must put the class into the a folder named helloworldapp, or you can remove the package declaration.
    I don't think the package statement is a problem for this use of the javac command. It will be a problem when the OP tries to execute the program if the class file is not in that folder and the java command is not issued in the folder containing the package folder and the package is left off with the java command:
    java helloworldapp.HelloWorldApp

  9. #9
    Junior Member
    Join Date
    Jul 2010
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: helloworld noob

    ok i changed the path to the jdk bin, and tried it again. good news no errors. bad news, nothing happened. i double checked and it runs in IDE fine still. Have any other ideas?

    I really do appreciate the help and patience!

  10. #10
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,139
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: helloworld noob

    nothing happened
    Can you show the console for your test.

    The javac command doesn't say anything if the compile was successful. Is there a .class file in the folder with the .java file?

  11. #11
    Junior Member
    Join Date
    Jul 2010
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: helloworld noob

    oh yeah i forgot it made the .class, i just expect things to go wrong, but now when i try to run it i get this *sigh*
    Attached Images Attached Images

  12. #12
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,139
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: helloworld noob

    Please read ALL of post#8.

  13. #13
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,139
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: helloworld noob

    Please copy and paste contents of command prompt window vs screen prints:
    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.

    can't seem to find a program anywhere that lets me open up a window for java
    Are you asking for something different than the command prompt window?

    To execute your program you need to be in the correct directory and issue the correct command. You are having a problem because of the package statement in your program. Remove the package statement and do it again and it should work.

Similar Threads

  1. HelloWorld
    By asbo in forum Member Introductions
    Replies: 1
    Last Post: March 22nd, 2010, 11:08 AM
  2. Need Help with my hmwk! Java noob!
    By ravij in forum Loops & Control Statements
    Replies: 4
    Last Post: October 7th, 2009, 01:02 AM