This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Confusion with Javac Compiler Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Confusion with Javac Compiler" Watch "Confusion with Javac Compiler" New topic
Author

Confusion with Javac Compiler

Jonathan Pro
Greenhorn

Joined: Apr 28, 2009
Posts: 5
So I finally started reading into programming today and came across a roadblock.
How do I add an entry to PATH environment variable that points to the bin in java directory?
I'm a beginner reading Head First Java.
I forgot to mention I'm using Notepad.
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3838

It depends on the environment you are using (Windows,Linux/Unix etc..). Here is the place contains all the details a beginner may need.

And Welcome to JavaRanch as well to the World of Java


SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
Jonathan Pro
Greenhorn

Joined: Apr 28, 2009
Posts: 5
Thanks for the quick reply and welcome.
That Beginner FAQ helped a lot, I guess I should've searched around before making a new thread so quickly.
I have errors on it though, it says "Could not find main class"
Here's my code:

Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3838

I forgot to mention I'm using Notepad


It's good to use a editor other than an IDE in the first place but notepad is a very basic editor. There are good editors availble on the web though.

I have errors on it though, it says "Could not find main class"


Did you able to compile it succesfully? Is the error comes when you run it? If Can you post the full stack trace?

Jonathan Pro
Greenhorn

Joined: Apr 28, 2009
Posts: 5
I couldn't compile it to a class and how do I post the full stack trace?
I'm prolly annoying you right now. lawl
When I tried to compile it said:
error: Class names, 'DooBee.app', are only accepted if annotation processing is explicitly requested. 1 error.
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3838

Jonathan Pro wrote:When I tried to compile it said:error: Class names, 'DooBee.app', are only accepted if annotation processing is explicitly requested. 1 error.


How you named your java source file ?What is DooBee.app? Seems you have put the source file in a package and use wrong name ? What is the command you use to compile ? (I assume you have set the PATH properly and working from command line ?)


Jonathan Pro
Greenhorn

Joined: Apr 28, 2009
Posts: 5
I made a typo, it was DooBee.java.
I don't know how to set the path.
I'm using Vista and I found the path variable thing but would this be the path I input?
C:\Program Files\Java\jdk1.6.0_11\bin
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3838

I think you should take a look at this (specific link from my previous post). Just follow that tutorial and you will be ready to go .
Jonathan Pro
Greenhorn

Joined: Apr 28, 2009
Posts: 5
I did follow it but it's not working. :/
My Java directory is also in my Program Files and not root C.
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3838

What is the error you are getting now? Try "echo %path%" in command prompt to see what's in your path variable and post it here. If you don't have it pointing to the bin directory of your JDK installation you have to add that to the path variable (through environment variables in Advanced System Properties - for Windows).
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39478
    
  28
Java™ Tutorials. There are sections about installing Java, and you find a link to setting the PATH in the "common problems" page.
Somebody said not to use NotePad: agree. Try NotePad2, NotePad++ or jEdit, but jEdit requires Java to be working.
Create a "java" folder to contain your work somewhere. Try opening a command prompt, thenand you are in your java folder, which you have probably created in "My Documents".
If you start getting errors like "annotation processing enabled" that suggests you have in fact installed Java correctly and have set your PATH correctly already. The error caused by not setting the PATH usually reads "javac is not recognized as a . . ."
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Confusion with Javac Compiler