• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JAVAC not found ??? I cant compile - help

 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
im just learning java and i got a compiler and everything set up and im ready to learn java from this book i have

the compiler tells me it cannot find JAVAC... here is a pic:


 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ?
 
Ryan Shaw
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
what do i change it to so i can compile the file Party.java inside that folder?
 
Sheriff
Posts: 9707
43
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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??
 
Ryan Shaw
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
dont worry, i worked it out i replaced xtra.bat with


all working now
 
Marshal
Posts: 79151
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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

it works and we leave it at this
 
Ranch Hand
Posts: 2908
1
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I hope this is just a practices code and not a homework, because naming directory as "java shit" just harm your grade if tutor is die hard Java fan
 
Ryan Shaw
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
DONT WORRY! im just starting to learn java and this is all practice
 
Campbell Ritchie
Marshal
Posts: 79151
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
*************.... always me isnt it???

i set the ************* classpath and the path etc etc and oh look



 
Ryan Shaw
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OK, i have calmed down...


javac is not recognised and im 100% sure the path and classpath are correct.

please help?
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ryan Shaw
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Marshal
Posts: 79151
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

And watch for my next post.
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The Sun Java Tutorial is also helpful; check out the ""Hello World!" for Microsoft Windows" and "Common Problems (and Their Solutions)" pages in http://java.sun.com/docs/books/tutorial/getStarted/index.html
 
Campbell Ritchie
Marshal
Posts: 79151
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Marshal
Posts: 79151
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
    Marshal
    Posts: 79151
    377
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    I have to go, shall not be available for several hours. Have you got it to work yet?
     
    Ryan Shaw
    Greenhorn
    Posts: 27
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    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
    Rancher
    Posts: 43081
    77
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    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
    Posts: 27
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    i dont know what command lines to use for what and the help doesnt make any sense
     
    Ulf Dittmer
    Rancher
    Posts: 43081
    77
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    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
    Posts: 27
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    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
    Rancher
    Posts: 43081
    77
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    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
    Posts: 27
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    im running command prompt from my start menu... what do you mean by change the directory?
     
    Ulf Dittmer
    Rancher
    Posts: 43081
    77
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    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
    Posts: 27
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    i get this when trying to run the file Party and i have compiled it


     
    Ulf Dittmer
    Rancher
    Posts: 43081
    77
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    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
    Posts: 27
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    well this is my results i think something is seriously wrong


     
    Ulf Dittmer
    Rancher
    Posts: 43081
    77
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    In programming you need to pay attention to detail. There's a space character between the "." and "party".
     
    Ryan Shaw
    Greenhorn
    Posts: 27
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    Ulf Dittmer wrote:In programming you need to pay attention to detail. There's a space character between the "." and "party".



    you sure?
    i cant see the space?? check again...
     
    lowercase baba
    Posts: 13089
    67
    Chrome Java Linux
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    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.
     
    Ryan Shaw
    Greenhorn
    Posts: 27
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    its in my notepad but still no space... what are you guys on??
    Untitled.jpg
    [Thumbnail for Untitled.jpg]
    no space here
     
    Ranch Hand
    Posts: 1296
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    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
     
    Ryan Shaw
    Greenhorn
    Posts: 27
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    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


     
    Sheriff
    Posts: 22781
    131
    Eclipse IDE Spring VI Editor Chrome Java Windows
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    The class is found but there is no "public static void main(String[] args)" method.
     
    Ryan Shaw
    Greenhorn
    Posts: 27
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    but i did just what the book told me to do?

    the book cant possibly be wrong!
    Untitled.jpg
    [Thumbnail for Untitled.jpg]
    well this is the page...
     
    Garrett Rowe
    Ranch Hand
    Posts: 1296
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    That snippet is not a complete working program.
     
    Don't get me started about those stupid light bulbs.
    reply
      Bookmark Topic Watch Topic
    • New Topic