• 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 making a .class file

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello.

First and foremost - I am a beginning beginner. I'm struggling with even getting HelloWorldApp.java to compile.

I set my path for javac, yet when I run the compiler, nothing happens. No error, no class file created.

What it looks like when I call the compiler -

C:\Users\Dwayne\java>PATH javac HelloWorldApp.java

I then type dir to see if the class file was created - no luck.

I have set my classpath and have used the echo function to check it.

C:\Users\Dwayne\java>echo %classpath%
C:\Users\Dwayne\java

I have Vista as an OS. Can anyone help me? Let me know if you need to know more.
[ November 09, 2008: Message edited by: Desirae Starling ]
 
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Desirae.

You're actually using the command PATH on the command line before javac? AS in

C:\Users\Dwayne\java>PATH javac HelloWorldApp.java

??

This is incorrect. The executable file 'javac.exe' that exists within your JDK installation directory needs to be found within the PATH setting on your machine (to recall it easily that is). It works like this: 'javac.exe', if you installed the JDK to the default directory, should be in C:\Program Files\Java\jdk_VERSION\bin. You should use Windows Explorer to verify this. If that's the case, then the command line has no idea how to find the command "javac" to execute and compile the .java source code file into bytecode. Same thing for the 'java', 'jar' and 'javadoc' commands. The PATH environment variable needs to be altered to include that 'bin' directory so the command line can find it. Otherwise you have to do something like this:

C:\Program Files\Java\jdk_VERSION\bin\javac.exe HelloWorld.java

Do a quick search on Google for "Windows Vista environment variables (PATH|CLASSPATH)". While you're at it, set an environmental variable JAVA_HOME to match your JDK installation directory (the aforementioned "C:\Program Files\Java\jdk_VERSION"

With the CLASSPATH, it should at least be set to '.' (the dot indicates the current working directory). So something like this should be returned when you request the %CLASSPATH% variable:
CLASSPATH=.

Just FYI, when I perform the install on my Win machines, I always install to C:\Java\jdk_VERSION, it just makes things easier in the long run. Then I install all Java related applications or libraries to a subdirectory under C:\Java and everything is in an easy to find place. Another good tip (if you're using JDK v6 as you should be) is to create a C:\Java\JAR directory and add that to your CLASSPATH as well, using C:\Java\JAR\* as a wildcard to any .jar file you store there.
[ November 09, 2008: Message edited by: Brian Lang ]
 
Marshal
Posts: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to JavaRanch

Slight point about the previous post; the PATH entry starts with C:\ (usually) and ends with bin, not javac.exe. It is the name of the directory the executable files are in.
The advice to create a separate directory to hold yoru own files is ver good.
The CLASSPATH need only contain the . which might appear as . .; ;. or ;.;
 
Brian Lang
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for pointing that out, I've edited my post.
 
Campbell Ritchie
Marshal
Posts: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Brian Lang:
Thanks for pointing that out, I've edited my post.



 
Desirae Starling
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks much. I've been reading so much about the CLASSPATH and PATH that it's getting hard to tell what is what. I've never worked with these things before. :/ I thought learning Java would be a challenge. Little did I know that my first roadblock would be understanding how to use the compiler. haha. I'll be back to let you know how it's going.
 
Campbell Ritchie
Marshal
Posts: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Once you have worked out how to do it, you can set the PATH correctly in a minute or two, but lots of people really struggle with it. That is why, if you find the problems page in the Java� Tutorials, this is the first problem they describe.
At this stage you only want the . in your CLASSPATH, but the bit about adding a jars folder sounds a good trick for use later on.
 
Desirae Starling
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Alright, I had the PATH set incorrectly. I thought it was correct because when I typed PATH in the command line I didn't get the usual error. But, all is well now. I thought my problem HAD to be different from everybody elses, so I posted. Sorry.

Thanks for your help!
 
Campbell Ritchie
Marshal
Posts: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Nothing to be sorry about; you had a problem and you sought help. We tried to help.

What we are interested in is: Have you got it working?
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey I am having the same problem where "javac HelloWorldApp.java" is not printing any errors, but no .class file is being made. I am fairly sure my PATH variable is correct - C:\Program Files\Java\jdk1.6.01_01\bin - but since there isn't any error, I have no clue what is going on. The spelling for the .java file and the installation of the compiler to the indicated folder are both correct. PLEASE HELP!
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to JavaRanch.

Have a look at Sun's Hello World tutorial, which explains in small steps how to write, compile and run your first Java program.
 
Campbell Ritchie
Marshal
Posts: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is there actually a 1.6.01 version of Java? I could only find 1.6.00_14.
 
reply
    Bookmark Topic Watch Topic
  • New Topic