• 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

the compilers not computing man!

 
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I keep getting this miserable noclassDefFoundError when i run from cmd.exe which of course means the OS can't find the compiler right? When I look in the 'c:\Program Files\java\jdk1.6\bin' folder I don't see any file or folder named 'javac'. Where is the compiler?...and do I need to edit or add any environment variables? Could that be a possible culprit? I know about compiling the source files first to produce the .class files but it always says: 'javac' is not an internal or externally recognized command...
 
Sheriff
Posts: 11343
Mac Safari Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Marcus Deviln wrote:...do I need to edit or add any environment variables? Could that be a possible culprit? ...


Indeed. See step 4 of Java 6 JDK installation instructions for Windows (32 bit). Updating your PATH variable will allow your system to find the java compiler regardless of your current directory.
 
marc weber
Sheriff
Posts: 11343
Mac Safari Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Marcus Deviln wrote:... When I look in the 'c:\Program Files\java\jdk1.6\bin' folder I don't see any file or folder named 'javac'...


Hmmm, there should be a javac.exe file under that directory.

Presumably, this is where you're telling your system to look by updating your PATH variable. So if the compiler isn't there, updating the PATH won't do it.
 
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

Marcus Deviln wrote:I keep getting this miserable noclassDefFoundError when i run from cmd.exe which of course means the OS can't find the compiler right?


No, a NoClassDefFoundError does not mean that the OS cannot find the compiler. It means that the Java runtime environment cannot find a Java *.class file that's needed to run a Java program.

Marcus Deviln wrote:When I look in the 'c:\Program Files\java\jdk1.6\bin' folder I don't see any file or folder named 'javac'. Where is the compiler?


That's odd; there should be a javac.exe in the bin folder of the JDK. If it isn't there, then your JDK installation most likely got corrupted somehow; try re-installing the JDK.

Marcus Deviln wrote:...and do I need to edit or add any environment variables? Could that be a possible culprit? I know about compiling the source files first to produce the .class files but it always says: 'javac' is not an internal or externally recognized command...


You have to add the bin directory of the JDK to the PATH, as the JDK installation instructions tell you (see marc's link above).
 
Marcus Deviln
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello folks! Just a little update here on the above mentioned problem. I managed to get my source file compiled. how do I know? I see the ".class" file next to the ".java" file in the jdk1.6.0_20 folder. I set the environment variables for user and system as follows: PATH and c:\Java\jdk1.6.0_20\bin for the value. That step preceded successful compilation. By the way I was able to get this far because taking the advice I was given I re-downloaded the jdk and sure enough the compiler was present. When I try to use the java command it's that same block of exceptions" exception in main thread..." I also read and re-read the installation instructions from the jdk and I feel like I've tried everything that my tiny little mind can come up with. In other words I'm out of ideas so any advice would be greatly appreciated.
 
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Marcus Deviln wrote:When I try to use the java command it's that same block of exceptions" exception in main thread..."




Well, it might help us if you tell us what the "block of exceptions" is... Maybe cut and paste the output on the screen to here.

Henry
 
Marcus Deviln
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
10-4 Henry sorry 'bout the omission

c:\Java>java Child.java
Exception in thread "main" java.lang.NoClassDefFoundError: Child
Caused by: java.lang.ClassNotFoundException: Child.java
at java.net.URLClassLoader$1.run(URLClassLoader.java:202
at java.security.AccessController.doPrivileged(Native Me
at java.net.URLClassLoader.findClass(URLClassLoader.java
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.j
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
Could not find the main class: Child.java. Program will exit.
 
Rancher
Posts: 618
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try:
java Child

You compile Child.java to produce Child.class and run the Child.class (but you don't specify .class when running it)
 
Marcus Deviln
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
check this out:



C:\Windows\System32>java Child
Error: could not open `C:\Program Files\Java\jre6\lib\i386\jvm.cfg'
 
Bartender
Posts: 1849
15
Eclipse IDE Spring VI Editor Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Marcus Deviln wrote:
c:\Java>java Child.java
Exception in thread "main" java.lang.NoClassDefFoundError: Child
Caused by: java.lang.ClassNotFoundException: Child.java
at java.net.URLClassLoader$1.run(URLClassLoader.java:202
at java.security.AccessController.doPrivileged(Native Me
at java.net.URLClassLoader.findClass(URLClassLoader.java
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.j
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
Could not find the main class: Child.java. Program will exit.



You need to do this first:
javac Child.java

And THEN (upon successful compilation)
java Child

if the first command results in windows saying invalid command (or whatever), you'll need to check your PATH in the system attributes.
 
Janeice DelVecchio
Bartender
Posts: 1849
15
Eclipse IDE Spring VI Editor Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Marcus Deviln wrote:check this out:



C:\Windows\System32>java Child
Error: could not open `C:\Program Files\Java\jre6\lib\i386\jvm.cfg'



Why are you compiling/running from the system32 folder?? Make a folder specifically for your programs and then compile/run from there.

As for could not open jvm.cfg, do you have a different version of JVM for the version of JDK you are using?
 
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
run these two commands, and tell us the results:

java -version
javac -version

you should get something like this:


C:\>java -version
java version "1.6.0_20"
Java(TM) SE Runtime Environment (build 1.6.0_20-b02)
Java HotSpot(TM) Client VM (build 16.3-b01, mixed mode, sharing)

C:\>javac -version
javac 1.6.0_20

C:\>


This will tell us if your compiler and run-time are in sync.
 
Marcus Deviln
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
C:\Windows\System32>java -version
Error: could not open `C:\Program Files\Java\jre6\lib\i386\jvm.cfg'

C:\Windows\System32>javac -version
javac 1.6.0_20

C:\Windows\System32>java -version
Error: could not open `C:\Program Files\Java\jre6\lib\i386\jvm.cfg'
 
marc weber
Sheriff
Posts: 11343
Mac Safari Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Marcus Deviln wrote:...Error: could not open `C:\Program Files\Java\jre6\lib\i386\jvm.cfg'...


Does that file exist (in that exact location)?
 
Marcus Deviln
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Does 'jvm.cfg' exist in that exact location? the answer is no, it exists at c:\Java\jre6\lib\i386
 
Marcus Deviln
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I moved the Java folder into the Program Files directory and when I type: java -version...

c:\Program Files\Java>javac Child.java
javac: file not found: Child.java
Usage: javac <options> <source files>
use -help for a list of possible options

c:\Program Files\Java>javac -version
javac 1.6.0_20

c:\Program Files\Java>java -version
java version "1.6.0_20"
Java(TM) SE Runtime Environment (build 1.6.0_20-b02)
Java HotSpot(TM) Client VM (build 16.3-b01, mixed mode, sharing)

c:\Program Files\Java>

...so now the java version is showing up
 
Janeice DelVecchio
Bartender
Posts: 1849
15
Eclipse IDE Spring VI Editor Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Marcus Deviln wrote:I moved the Java folder into the Program Files directory and when I type: java -version...

c:\Program Files\Java>javac Child.java
javac: file not found: Child.java
Usage: javac <options> <source files>
use -help for a list of possible options

c:\Program Files\Java>javac -version
javac 1.6.0_20

c:\Program Files\Java>java -version
java version "1.6.0_20"
Java(TM) SE Runtime Environment (build 1.6.0_20-b02)
Java HotSpot(TM) Client VM (build 16.3-b01, mixed mode, sharing)

c:\Program Files\Java>

...so now the java version is showing up



so now you need to navigate to the directory where you saved Child.java and try again!

If you use notepad++ there's an option in the run... menu that will open the cmd prompt in the folder the file is located.
 
Marcus Deviln
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
C:\Windows\System32>cd c:\Program Files\Java\jdk1.6.0_20

c:\Program Files\Java\jdk1.6.0_20>java Child
Variable x is 9



OK great one step taken with several miles to go lovely...
 
Janeice DelVecchio
Bartender
Posts: 1849
15
Eclipse IDE Spring VI Editor Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Create yourself a folder for the java files you write... keep your stuff out of the jdk folder and the system32 folder and everything else.

Great Job!!
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic