*
The moose likes Beginning Java and the fly likes JDK malfunction Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "JDK malfunction" Watch "JDK malfunction" New topic
Author

JDK malfunction

Joshua Horowitz
Greenhorn

Joined: Aug 18, 2009
Posts: 3
I recently installed JDK SE on my computer, I then moved the content of the bin folder to the windows directory so that I could use it without pointing to c:\java\bin every time. Now when I try to use the javac command I get the error shown below (I copied it by hand so there might be some errors but it's almost completely correct). I know it's not my program because i tried copying the hello world program from this website and I got the same error. Thank you for your help.

Exception in thread "main" Java.lang.NoClassDefFoundError: com/sun/tools/javac/main
Caused by: java.lang.ClassNotFoundException: com.sun.tools.javac.Main
at java.net.VRLClassLoader$1.run(unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
Could not find the main class: com.sun.tools.javac.main. Program will exit.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18141
    
    8

Joshua Horowitz wrote:I recently installed JDK SE on my computer, I then moved the content of the bin folder to the windows directory so that I could use it without pointing to c:\java\bin every time.


Don't do that. Read this tutorial for getting started with Java on Windows.
Nitish Bangera
Ranch Hand

Joined: Jul 15, 2009
Posts: 537

THis is not a JDK malfunction. Its just not finding the class file that you are specifying in the java keyword


[ SCJP 6.0 - 90% ] , JSP, Servlets and Learning EJB.
Try out the programs using a TextEditor. Textpad - Java 6 api
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 13875
    
  10

Joshua moved the content of the bin folder of the JDK to his Windows directory. That doesn't work at all and messes up the JDK. The error message means that the JDK can't find the Java compiler.

Instead of doing what you did, you should read and follow the JDK installation instructions carefully. Especially take note of step 4: Update the PATH variable. That will make sure that you can just type "java" and "javac", so that you don't need to specify the whole path to the JDK bin directory.

Don't just copy all kinds of files to your Windows directory - that can seriously mess up your computer.

And welcome to JavaRanch, Joshua.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
Raghu Devatha
Ranch Hand

Joined: Feb 10, 2009
Posts: 39
Also, don't install in "Program Files". May create problems.


dR
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 36514
    
  16
Raghu Devatha wrote:Also, don't install in "Program Files". May create problems.
Yes, you can. It is normal for the Java™ installer to create a "Java" sub-directory of "Program Files".

If you mean, "Don't put your own work in Program Files", however, that is very good advice.
Raghu Devatha
Ranch Hand

Joined: Feb 10, 2009
Posts: 39
Campbell Ritchie wrote:
Raghu Devatha wrote:Also, don't install in "Program Files". May create problems.
Yes, you can. It is normal for the Java™ installer to create a "Java" sub-directory of "Program Files".

If you mean, "Don't put your own work in Program Files", however, that is very good advice.


Yes, we can, but because of the space between Prgoram and Files, I ran into problems.
Joshua Horowitz
Greenhorn

Joined: Aug 18, 2009
Posts: 3
Thank you for your help. I followed the instructions and made an environment variable pointing at C:\java\bin\ which is the directory moved java to and it still wont work. Any suggestions?
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 10916
    
  12

"it still won't work" really doesn't tell us much of anything. It will tell you EXACTLY what is wrong. Now, you may not understand it, but that's no big deal. that's what we can help with. But without telling us what the problem really is, there is not much anyone can do.


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 36514
    
  16
The usual Java installation folder on Windows is C:\Program Files\java\jdk1.6.0_14\bin (for JDK6u14: the numbering should be easy to understand). You want to add what I marked in bold/underline to your PATH. C:\Java\bin will probably not work.

It may sometimes be necessary to put "" round a PATH element with spaces in.
Joshua Horowitz
Greenhorn

Joined: Aug 18, 2009
Posts: 3
It seems like all the Java files are there in c:\java

Directory of C:\Java

08/23/2009 02:36 AM <DIR> .
08/23/2009 02:36 AM <DIR> ..
08/16/2009 12:14 AM <DIR> bin
07/31/2009 04:29 PM 3,841 COPYRIGHT
08/16/2009 12:17 AM <DIR> demo
08/23/2009 02:36 AM 0 dir.txt
08/16/2009 12:14 AM <DIR> include
08/16/2009 12:15 AM <DIR> jre
08/16/2009 12:16 AM <DIR> lib
08/16/2009 12:14 AM 17,524 LICENSE
08/16/2009 12:14 AM 17,632 LICENSE.rtf
08/16/2009 12:14 AM 29,043 README.html
08/16/2009 12:14 AM 25,828 README_ja.html
08/16/2009 12:14 AM 21,275 README_zh_CN.html
08/16/2009 01:06 AM 5,329 register.html
08/16/2009 01:06 AM 5,748 register_ja.html
08/16/2009 01:06 AM 4,926 register_zh_CN.html
08/16/2009 12:18 AM <DIR> sample
07/31/2009 04:30 PM 19,641,221 src.zip
08/16/2009 12:14 AM 252,567 THIRDPARTYLICENSEREADME.txt

I changed System Variable so it looks like this:

Variable name: JAVA_HOME
Variable value: C:\java\bin\

I also tried putting the value in quotes.

When I try to run the javac command I get the is not recognized as an internal or external whatever message. However when I use it as "C:\java\bin\javac.exe" it works. But the java command works in command prompt without the full file path needed.

I'm stumped do you guys have any ideas?
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 36514
    
  16
Are you using JAVA_HOME or a PATH variable? If you use JAVA_HOME you usually omit the "bin". Use that as a PATH component, starting with C and ending with bin, not \.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JDK malfunction
 
Similar Threads
Error in run a java program in another director
UnsupportedClassVersionError (unsupported major.minor version 50.0)
Running a java program with full path\class name
Error To run a java Program in another Dir
Runtine Exception UnsupportedClassVersionError