• Post Reply Bookmark Topic Watch Topic
  • New Topic

Java 1.42 JDK Help needed  RSS feed

 
David Hunt
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • 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.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 37513
554
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • 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
  • 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
 
Eric Sexton
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • 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?
 
Dave Vick
Ranch Hand
Posts: 3244
  • Mark post as helpful
  • send pies
  • 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.
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
  • 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
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!