Looking at the picture, it seems that the problem is not that javac is not found, but that .\Server\*.java is not found. Are you sure about this path ?
Is the Server folder inside the "java shit" folder?? And when you've set the path env variable, then why are you using the complete path to javac.exe in xtra.bat??
dont worry, i worked it out i replaced xtra.bat with
all working now
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32644
4
posted
0
Why are you adding the location of your java tool or the lib directory to the classpath? You ought not to put any of your own code into the Java installation folder, and you ought not to put the Java installation folder into your classpath.
Ryan Shaw
Greenhorn
Joined: Jun 04, 2009
Posts: 27
posted
0
the thing is... i have a screwed up computer that doesnt know what javac is even though its in the environment variables and told to. and if you studied the code closely you would realise that my own data actually ends up in the folder the .java is in what is called Java Shit on my desktop... nothing is added to the install directory
DONT WORRY! im just starting to learn java and this is all practice
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32644
4
posted
0
Try the following at the command line:
javac -version
java -version
If you get anything sensible, like a version number or "HotSpot", then you have correct access to java and javac. The screenshot you posted earlier (by the way, look at this FAQ which might let you get away without screenshots; the screenshot makes the message "wider" than my screen) suggests you are getting errors from javac, so you are actually accessing javac correctly.
If you get error messages like "javac is not recognised as a file or directory or executable program," then look at this Java™ Tutorials page. That sort of message is caused by not having your system PATH variable set. The link gives you instructions how to set the PATH; you will almost certainly want the "set permanently" option.
Ryan Shaw
Greenhorn
Joined: Jun 04, 2009
Posts: 27
posted
0
*************.... always me isnt it???
i set the ************* classpath and the path etc etc and oh look
Ryan Shaw
Greenhorn
Joined: Jun 04, 2009
Posts: 27
posted
0
OK, i have calmed down...
javac is not recognised and im 100% sure the path and classpath are correct.
please help?
Ulf Dittmer
Marshal
Joined: Mar 22, 2005
Posts: 35232
7
posted
0
Looking at the screenshot, both PATH and CLASSPATH look screwed up. If there really are equal signs and the words "PATH" and "CLASSPATH" inside of them, then they won't work.
well can you offer a solution for me to put into my path and classpath in environment variables??? according to the java site im supposed to have % and = in there...
Ulf Dittmer
Marshal
Joined: Mar 22, 2005
Posts: 35232
7
posted
0
For PATH, something like "C:\Windows\System 32;C:\Program Files\Java\jdk1.6.0_12\bin" would seem OK.
Equals signs are part of the "SET" command that sets the PATH, but not part of PATH itself.
I recommend not to use CLASSPATH at all. If for some reason you're set on using it, then the "bin" and "lib" directories of the JDK installation should not be part of it; they do not contain class files.
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32644
4
posted
0
You don't really need anything in your CLASSPATH. I can't remember how you get at your environment variables in WinVista, but it something to do with r-click "my computer" --> properties --> advanced --> environment variables. At least that's what you do on WinXP, but there is a difference with the first stage on WinVista.
If there is anything in the CLASSPATH which you haven't added yourself, add this to the beginning of the CLASSPATH
.;
and delete anything you added yourself in the last 24 hours. Some applications, eg QuickTime, set up their own CLASSPATH without the . in. The . means "current directory" and once you have got that set up, you will probably never need to change your system CLASSPATH ever.
If there is nothing in the CLASSPATH which you haven't added yourself, delete the entire CLASSPATH.
On the same window as setting your CLASSPATH, you will find the PATH. This is the one you really do have to set. From the messages you got earlier, you appear to be using the JRE version of "java" which means you can run any Java program, but can't compile anything. The "javac is not recognised" error is typical of what you get if you don't set the system PATH. You can set "user PATH" or "system PATH"; you might as well set "system PATH" then everyboyd using that PC will have access to the JDK. Ulf has just given you an example of what to set.
Also, delete any references to old versions of Java from your PATH.
A PATH entry for Java begins with the Drive letter, usually C, and ends with bin.
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32644
4
posted
0
And why are you using batch files or the -d option, when you are just beginning? I hope your book doesn't recommend them, at least not until you get at least half-way through the book. At this stage you want to keep things as simple as possible.
Ulf has told you where to find the "Hello World" examples in the Java™ Tutorials, so what you do is
Open a command line
navigate to your Java directory with the cd command. You might need "" round the name of the directory if it contains whitespace.
Edit a little tiny Java™ file, eg the HelloWorld.java file.
Don't write any package declarations in your .java files at this stage
Avoid using NotePad; download NotePad++ or NotePad2 which are much better editors for programming.
Save that .java file in the same directory
"Compile" the .java file with the following instruction:
javac HelloWorld.java
Execute it with the following command:
java HelloWorld
Note when you write the extension and when you don't. Note the instructions are mostly case-sensitive.
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32644
4
posted
0
I have to go, shall not be available for several hours. Have you got it to work yet?
Ryan Shaw
Greenhorn
Joined: Jun 04, 2009
Posts: 27
posted
0
i havent started my book and it doesnt have any "HELLO WORLD" rubbish...
i got my compiler from a friend as no one on this community would help me...
the compiler seems to compile everything in the folder...
???
a very confused person here
ahhhhhh the idea of me signing up here was to get help for getting batch files that will compile my .java and to fix the stupid path and classpath
AND I HAVE MANAGED TO FIX MY PATH AND CLASS PATH
all i need now is instructions on how to open and compile with command prompt
Ulf Dittmer
Marshal
Joined: Mar 22, 2005
Posts: 35232
7
posted
0
I recommend to forget about batch files for the moment. Try to get it to work reliably from the command line first. Which commands are you using now to do that, and what are the results?
Ryan Shaw
Greenhorn
Joined: Jun 04, 2009
Posts: 27
posted
0
i dont know what command lines to use for what and the help doesnt make any sense
Ulf Dittmer
Marshal
Joined: Mar 22, 2005
Posts: 35232
7
posted
0
I think we could sort that out quickly if you told us, precisely, how you are trying to compile - the commands you enter, the response you get, etc.
Anything with a space in it most likely needs to be contained in double quotes, lest it gets misinterpreted. If you're not entirely comfortable with the command line, it would be easier to use a directory name that doesn't contain spaces.
Ryan Shaw
Greenhorn
Joined: Jun 04, 2009
Posts: 27
posted
0
Ulf Dittmer wrote:I think we could sort that out quickly if you told us, precisely, how you are trying to compile - the commands you enter, the response you get, etc.
Anything with a space in it most likely needs to be contained in double quotes, lest it gets misinterpreted. If you're not entirely comfortable with the command line, it would be easier to use a directory name that doesn't contain spaces.
yeh i took the space out now... what command do you use to compile and what command do i use to run?
Ulf Dittmer
Marshal
Joined: Mar 22, 2005
Posts: 35232
7
posted
0
First of all, instead of starting out in the C:\Windows\System32 directory, you need to change to the directory where your source resides. Something like "cd C:\Users\Ryan\Desktop\whatever" should do the trick.
Then you need to specify which files to compile. You can either compile single files ("javac MyFile.java") or use a wildcard to compile all files ("javac *.java").
Finally, to run the code, use "java MyFile" or "java -classpath . MyFile".
This is all explained in detail in the Sun Java Tutorial which I linked to earlier.
Ryan Shaw
Greenhorn
Joined: Jun 04, 2009
Posts: 27
posted
0
im running command prompt from my start menu... what do you mean by change the directory?
Ulf Dittmer
Marshal
Joined: Mar 22, 2005
Posts: 35232
7
posted
0
I mean to type in "cd C:\Users\Ryan\Desktop\whatever" after opening the command prompt, and then to hit the return key.
Ryan Shaw
Greenhorn
Joined: Jun 04, 2009
Posts: 27
posted
0
i get this when trying to run the file Party and i have compiled it
Ulf Dittmer
Marshal
Joined: Mar 22, 2005
Posts: 35232
7
posted
0
Do you have a file called "party.class" in that directory? If so, you can run it using "java party" or "java -classpath . party" (previous posts of mine as well as Campbell actually mention doing exactly that).
The "java" command does not take a file name as argument, it takes a class name.
I really think a thorough reading of the Tutorial (or whatever introductory book you're using) would be beneficial at this point.
Ryan Shaw
Greenhorn
Joined: Jun 04, 2009
Posts: 27
posted
0
well this is my results i think something is seriously wrong
Ulf Dittmer
Marshal
Joined: Mar 22, 2005
Posts: 35232
7
posted
0
In programming you need to pay attention to detail. There's a space character between the "." and "party".
Ryan Shaw
Greenhorn
Joined: Jun 04, 2009
Posts: 27
posted
0
Ulf Dittmer wrote:In programming you need to pay attention to detail. There's a space character between the "." and "party".
There is a space between the dot and the word party. you can always cut'n'paste it into something like notepad if you want to confirm it's really there.
Never ascribe to malice that which can be adequately explained by stupidity.
Ryan Shaw
Greenhorn
Joined: Jun 04, 2009
Posts: 27
posted
0
its in my notepad but still no space... what are you guys on??
Garrett Rowe
Ranch Hand
Joined: Jan 17, 2006
Posts: 1295
posted
0
That's the problem. There is a space in Ulf and Campbell's example, but there is no space in your command. The command should look like this:
java -classpath . party
Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them. - Laurence J. Peter
Ryan Shaw
Greenhorn
Joined: Jun 04, 2009
Posts: 27
posted
0
Garrett Rowe wrote:That's the problem. There is a space in Ulf and Campbell's example, but there is no space in your command. The command should look like this:
java -classpath . party
ok... whats wrong this time... i have the space lol