• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Java 1.42 JDK Help needed

 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I am just starting Java as a Programming language. I need some help in getting started, especially installing Java program to start programming at home. I downloaded Java 1.42 JDK from the sun website for windows XP. I have typed up the HelloWorldApp.java example from the Java.sun website and have tried to run it from the command line, by typing
javaw HellopWorldApp.java (which i think is right)
It just responds with a pop up message saying 'Could not find the main class. Program will exit'
Any ideas anyone.
Help would be much appreciated.
 
author & internet detective
Posts: 42003
911
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There is a two step process. First you compile the class, then you run it. Note that when running it you don't put the .java extension.
>javac HellopWorldApp.java
>java HellopWorldApp
 
David Hunt
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
First of all thanks for the Quick reply!
But I here what you say but I have already tried what you said and it just comes up with the error I stated after stage one when I type the command:
javaw HelloWorldApp.java
 
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've never used the "javaw" before..

Did the program compile and is there a class file in the folder you created the source in?
 
Ranch Hand
Posts: 3244
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
David
Like Jeanne said the fist thing you do is type:
javac HellopWorldApp.java
on the command line. this compiles your file with the .java extension into a .class file. After it is compiled then you type:
java HellopWorldApp
When you run it don't put the extension, just the class name. So the questions for you are:
When you type 'javac HellopWorldApp.java' does it compile without errors or is this where you get the error? If you get no errors there then enter:
java HellopWorldApp
and it should run. Is this where you get the error?
In your post you said you entered
javaw HellopWorldApp.java
which would be wrong if you're tying to run the app, try it without the extension, assuming that it compiled correctly.
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
David --
Welcome to JavaRanch!
You actually did -not- do what Jeanne suggested: you tried to feed a *.java file to javaw, whereas you'll note that Jeanne did not include the .java part. Compiling HelloWorldApp.java with javac creates HelloWorldApp.class. This is the file that javaw can operate on. But even so, you must not type the ".class" part, either. Just type exactly what Jeanne shows, using no file extensions at all.
 
Eric Sexton
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Like I said earlier, I had never heard of javaw, but I did find this link. Read the description part.
 
David Hunt
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The first step when I try to compile the HelloWorldApp.java file when I type the command:
javac HelloWorldApp.java
it just gives the following error 'javac' is not recognized as an internal or external command, operable program or batch file
When I try:
javaw HelloWorldApp.java
it says: Could not find the main class. Program will exit (in a pop up)
Any ideas what I am doing wrong?
Thanks again
 
David Hunt
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have now SOLVED the problem. It was do with having to typing the whole path /bin etc to sho windows where the javac.exe was(I found it on the java.sun website)
So sorry for taking up your time, all your help was much appreciated any way. No doubt I will be back with more problems soon.
Thanks
 
It is no measure of health to be well adjusted to a profoundly sick society. -Krishnamurti Tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic