Problems regarding "Hello, World!"


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4

Thread: Problems regarding "Hello, World!"

  1. #1
    Join Date
    Aug 2006
    Posts
    1

    Problems regarding "Hello, World!"

    Hello, I have some small problems with running my first Java program through MSDOS. As a student starting a Computer Science course this October,I have been asked to familiarise myself with the language before the course begins.

    To begin with I downloaded the JDK Beta 2 here. I then followed this tutorial, also from the Sun site here.

    Now the problems initially occur when, after saving the code above as HelloWorldApp.java and then attempting to compile it in the command prompt window. I get an error message stating "javac is not a recognized external or internal command..."

    I have found a way around this by creating an env.bat file with the following:

    Code:
    SET JAVA_HOME=C:\Program Files\Java\jdk1.6.0
    
    SET PATH=%PATH%;%JAVA_HOME%\bin
    However surely I am not required to run env.bat each time I attempt to compile my program?

    -----

    The second problem then occurs after compiling the program and creating the corresponding .class file. After attempting to run the completed file I recieve another error message "Exception in thread "main" java.lang.NoClassDefFoundError:".

    Again I can get around this using:

    Code:
    java -cp . HelloWorldApp
    However, again this cannot be the correct way to go about running my program?

    Any help is much appreciated, as I have only just began to learn the language.

  2. #2
    Join Date
    Feb 2006
    Posts
    13
    I have installed JDK1.4 into c drive so I have written follwing command in system variable Path
    C:\Jdk1.4\bin
    After setting variable restart your computer.
    Now you can compile and run program from yor directroy.
    After writing source compile it using follwing command
    javac fileName.java

    Create HTML file for your applet writing this code in body tag.
    <APPLET CODE="FileName.class" WIDTH=150 HEIGHT=25>
    </APPLET>

    Type following on command prompt
    appletviewer Hello.html
    I hope this may help you.
    rathorek

  3. #3
    Join Date
    Dec 2005
    Location
    Arrr
    Posts
    32
    rathorek - I think he's asking about a console app, not necessarily an applet, and I would assume an entry level CSC course will begin with console apps.

    Lloyd9 - If you are using MSDOS only, put those commands in autoexec.bat, and restart your machine. They will load everytime the machine restarts so you don't have to run env.bat every time.
    Alternatively, if you are running Windows rather than just MSDOS, you can set the environment variables without a batch file. Open the System widget in your control panel, click the advanced tab, and click the 'Environment Variables' button. You can use that interface to add JAVA_HOME and modify your path statement to include \bin.

    Good luck, and feel free to PM me if you have any further install questions.

  4. #4
    Join Date
    Mar 2005
    Location
    UK, London
    Posts
    150
    Where did you install java to, if its the c drive then I usually, do this in my console

    path =c:\jdk1.5.0_06\bin

    javac test.java

    java test

    If that doesnt work you may have a problem with your enviroment variables. Check your computers eviroment variables.

Similar Threads

  1. Problems with MSSQLServer and Java
    By jlopes151 in forum Database
    Replies: 1
    Last Post: 11-21-2005, 05:32 AM
  2. Replies: 0
    Last Post: 07-19-2002, 02:41 AM
  3. Replies: 2
    Last Post: 05-29-2002, 02:38 PM
  4. Replies: 0
    Last Post: 10-04-2000, 05:05 AM
  5. RmiJdbc.RJJdbcServer Problems
    By Mike Jewson in forum Java
    Replies: 0
    Last Post: 06-01-2000, 01:32 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
  •  
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