Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

the compilers not computing man!

 
Marcus Deviln
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • 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...
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • 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
Java Mac Safari
  • Mark post as helpful
  • send pies
  • 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.
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15484
43
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • 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
  • 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.
 
Henry Wong
author
Marshal
Pie
Posts: 21504
84
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • 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
  • 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.
 
Tom Reilly
Rancher
Posts: 618
  • Mark post as helpful
  • send pies
  • 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
  • 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'
 
Janeice DelVecchio
Saloon Keeper
Posts: 1809
12
Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • 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
Saloon Keeper
Posts: 1809
12
Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • 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?
 
fred rosenberger
lowercase baba
Bartender
Posts: 12196
35
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • 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
  • 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
Java Mac Safari
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
Saloon Keeper
Posts: 1809
12
Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • 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
  • 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
Saloon Keeper
Posts: 1809
12
Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • 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!!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic