Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Go Back   Code Forums > Application and Web Development > Java
User Name
Password

Reply
 
LinkBack Thread Tools Display Modes
Old 02-02-2007, 12:15 PM   #1 (permalink)
virus0010010
Recruit
 
Join Date: Feb 2007
Posts: 13
virus0010010 is on a distinguished road
javac command doesnt work

hello,
I am new in java and I was reading this book, every thing was going well untill it was time to compile the program from the word proccesor.
The javac command doesnt work. I do have the latest version of jdk and when I type the (java -version) command, it does show me the version. But when its time to use the compile command, it just doesnt work. I get this: ('javac' is not recognised as an internal or external command, operable program or batch file.)

PLEASE HELP ME, I stopped reading the book because there is no point of reading it when I cant even compile a program
__________________
virus0010010 is offline   Reply With Quote
Old 02-03-2007, 04:51 AM   #2 (permalink)
Belisarius
Java fanboy
 
Belisarius's Avatar
 
Join Date: Aug 2003
Posts: 1,114
Belisarius is on a distinguished road
It's not in your PATH. The reason you can run "java" is because Windows installs the JRE by default, and so it's already available to you - you need to point Windows to the new install.

First find out where the copy you downloaded installed to. Usually it's in "C:\Program Files\Java". For instance, I have a copy of 1.5 on my machine, and it's installed in "C:\Program Files\Java\jdk1.5.0_06". Underneath that directory there is a "bin" directory. That is where Java keeps it's commands like "java" and "javac".

Next, right click on My Computer, go to Properties, click on the Advanced tab, and click on the Environmental Variables button. In the System Variables section, modify the "Path" variable to include that "bin" directory from before.

Also, to save yourself headaches in the future, make sure the CLASSPATH variable exists and includes ".", a period. It might contain other things, but make sure it contains that period, otherwise you'll have problems running your java programs.
__________________
GitS
Belisarius is offline   Reply With Quote
Old 02-03-2007, 08:18 AM   #3 (permalink)
virus0010010
Recruit
 
Join Date: Feb 2007
Posts: 13
virus0010010 is on a distinguished road
the bin diretory is included from the beggining.
I ddnt understand the last part of what you were saying.
Any ways, it still doesn't work. Any sudjestions?
__________________
virus0010010 is offline   Reply With Quote
Old 02-03-2007, 08:36 AM   #4 (permalink)
Belisarius
Java fanboy
 
Belisarius's Avatar
 
Join Date: Aug 2003
Posts: 1,114
Belisarius is on a distinguished road
The problem is that the "javac.exe" command isn't in the PATH. That's the reason you're getting that error message - it's not a problem with Java, per se, but a configuration problem with Windows. In some form or fashion, Windows can't find the command "javac". It will search through all the directories in the PATH variable to look for it, but if it can't find it, it will return the error message you are getting.

I'm sorry I can't be more helpful, but that is the immediate cause of your problems - the fact that "javac" isn't in any of the directories listed in the PATH variable. The only other thing I can think of is you might have a User variable that's over-riding the system variable, you can check that (it's located along with the System Variables box I described earlier).
__________________
GitS
Belisarius is offline   Reply With Quote
Old 02-04-2007, 02:37 AM   #5 (permalink)
virus0010010
Recruit
 
Join Date: Feb 2007
Posts: 13
virus0010010 is on a distinguished road
Thnx. It finally worked. But now I have another problem.
When I want to start the program using the (java) command, it doesn't work. I get this: (Exeption in thread "main" java.lang.NoClassDefFoundError: command).
I think what that basically means is that there isn't a class file in the folder which there is after compiling a program.
So, what should I do? Does it have to do with the path again?
__________________
virus0010010 is offline   Reply With Quote
Old 02-04-2007, 05:18 AM   #6 (permalink)
Belisarius
Java fanboy
 
Belisarius's Avatar
 
Join Date: Aug 2003
Posts: 1,114
Belisarius is on a distinguished road
No, it has to do with the CLASSPATH. Java can't find the class for the program you're calling. My guess is that you don't have ".", or what's known as the "working directory", in your CLASSPATH.
__________________
GitS
Belisarius is offline   Reply With Quote
Old 02-04-2007, 12:01 PM   #7 (permalink)
virus0010010
Recruit
 
Join Date: Feb 2007
Posts: 13
virus0010010 is on a distinguished road
oow. Where can I find CLASSPATH. Is it the same place where the path is? because if it is, then it isn't there.
__________________
virus0010010 is offline   Reply With Quote
Old 02-04-2007, 12:47 PM   #8 (permalink)
Belisarius
Java fanboy
 
Belisarius's Avatar
 
Join Date: Aug 2003
Posts: 1,114
Belisarius is on a distinguished road
Yes, and you need to put it there.
__________________
GitS
Belisarius is offline   Reply With Quote
Old 02-09-2007, 10:26 AM   #9 (permalink)
virus0010010
Recruit
 
Join Date: Feb 2007
Posts: 13
virus0010010 is on a distinguished road
How do I put the CLASSPATH there? details please.
__________________
virus0010010 is offline   Reply With Quote
Old 02-09-2007, 11:02 AM   #10 (permalink)
redhead
Newbie
 
redhead's Avatar
 
Join Date: Jun 2002
Location: Denmark
Posts: 1,680
redhead is on a distinguished road
Follow the advice Belisarius gives in #2, and bellow the "System variable" settings theres a "New" button, click that and add the CLASSPATH as variable -name, and "." as the value.
__________________
Don't worry Ma'am, We're university students, We know what We're doing.
-----
If you pull the pin, Mr.Grenade would no longer be your friend.
-----
01000111 01101111 00100000 01000011 00100000 00100001
redhead is offline   Reply With Quote
Old 02-09-2007, 12:52 PM   #11 (permalink)
virus0010010
Recruit
 
Join Date: Feb 2007
Posts: 13
virus0010010 is on a distinguished road
ow, ok. But I tryed doing that and nothing happened. the java command still doesn't work. Any ideas?
__________________
virus0010010 is offline   Reply With Quote
Old 02-09-2007, 03:37 PM   #12 (permalink)
Belisarius
Java fanboy
 
Belisarius's Avatar
 
Join Date: Aug 2003
Posts: 1,114
Belisarius is on a distinguished road
The java command is working fine, it's just a matter of debugging.

Have you created your class file as a package? That is, at the top of the file, did you say "package <some name>"?

Also, did you include a "main" method in your file? That is, is there a method that says:

Code:
static public void main(String[] args) { . . . }
Something to that effect?
__________________
GitS
Belisarius is offline   Reply With Quote
Old 02-10-2007, 09:18 AM   #13 (permalink)
virus0010010
Recruit
 
Join Date: Feb 2007
Posts: 13
virus0010010 is on a distinguished road
I did include a "main" method but how do I creat my class file as a package?
__________________
virus0010010 is offline   Reply With Quote
Old 02-10-2007, 10:49 AM   #14 (permalink)
redhead
Newbie
 
redhead's Avatar
 
Join Date: Jun 2002
Location: Denmark
Posts: 1,680
redhead is on a distinguished road
In your class file:
Code:
package mypackage.whatever; ... public class something { .... ... }
And in your main .java file:
Code:
import mypackage.whatever.*; public class someClass extends anotherClass { ... ... public static void main(String[] args){ // Something todo in main... } }
__________________
Don't worry Ma'am, We're university students, We know what We're doing.
-----
If you pull the pin, Mr.Grenade would no longer be your friend.
-----
01000111 01101111 00100000 01000011 00100000 00100001
redhead is offline   Reply With Quote
Old 02-10-2007, 03:51 PM   #15 (permalink)
Belisarius
Java fanboy
 
Belisarius's Avatar
 
Join Date: Aug 2003
Posts: 1,114
Belisarius is on a distinguished road
Well, in this case, I was worried that virus had packaged them, and was calling the file incorrectly. That's not the case, so don't worry about it.

Please post both the source code of the file you're attempting to run, as well as the command you entered and the output.
__________________
GitS
Belisarius is offline   Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Why doesn't this work? destin Standard C, C++ 2 03-31-2005 04:55 PM
Can't get loop to work rockybalboa Java 5 03-20-2005 03:54 PM
ASP.NET: Day / Work Week / Week / Month web calendar control with view like MS Outloo gicio MS Technologies ( ASP, VB, C#, .NET ) 0 12-10-2003 10:05 AM
San Diego Tech. work. Admin Lounge 10 02-03-2003 06:19 PM
Getting X to work in Debian w00t Linux / BSD / OS X 7 08-25-2002 01:44 PM


All times are GMT -8. The time now is 06:47 AM.


Powered by vBulletin Version 3.6.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2006, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting
Open Circle