File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem Compiling

 
T Dreezy
Greenhorn
Posts: 6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Everyone I'm TOTALLY new to Java/programming in general...

I typed in this source code:




However whenever I try and run it in the Command Prompt I don't get anything (I navigate to C:\(my java source file directory) javac MyFirstApp.java and press enter but nothing happens, the command prompt just shows C:\(java source file directory) again)

I already set the PATH environment variable. Before I did that I was getting an error.

Any help will be appreciated
 
Mohamed Sanaulla
Saloon Keeper
Pie
Posts: 3159
33
Google App Engine Java Ruby
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You might want to have look if the .class file has been created. Usually if the compilation is successful you don't get any message. Only if there are compilation errors would you see some messages.
 
Christophe Verré
Sheriff
Pie
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As Mohamed said, type "dir" and see if the class file was generated.
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Pie
Posts: 15150
31
Android IntelliJ IDE Java Scala Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch!

Please UseCodeTags when you post source code.

After successfully compiling your program with javac, you should have a file named MyFirstApp.class in your directory. You can then run your program with a command like this:

java MyFirstApp

You can find good tutorials here; especially have a look at the Getting Started tutorial which explains in detail how to write your first Java app and how to compile and run it, and explains common errors and their solutions that you might run into.
 
Christophe Verré
Sheriff
Pie
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jesper de Jong wrote:
You can find good tutorials here; especially have a look at the Getting Started tutorial which explains in detail how to write your first Java app and how to compile and run it, and explains common errors and their solutions that you might run into.

There's also a tutorial at the ranch
 
Deepak Chopra
Ranch Hand
Posts: 433
Eclipse IDE Firefox Browser Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A quick way to check if your classpath has been set properly - type javac and press enter on comman prompt in your source directory.
If it shows you - command not found, you may want to check your classpath otherwise as Mohamed said " type dir and check the class file".
 
Campbell Ritchie
Sheriff
Pie
Posts: 47293
52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch

You have had some good advice, probably the best being from Mohammed Sanaulla:
. . . Usually if the compilation is successful you don't get any message. . . .
The stony silence of the compiler when all goes well can be a bit disconcerting at first, but the simplest thing to do is assume all is well and proceed to the command Jesper told you about.
I have added code tags, since you are new, and you can see how much better the posting looks.
 
T Dreezy
Greenhorn
Posts: 6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks everyone I finally got it to work!
 
Christophe Verré
Sheriff
Pie
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
By the way, you can make him talk by using "javac -verbose MyFirstApp.java".
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic