• 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:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

JDK malfunction

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Sheriff
Posts: 28385
99
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
Ranch Hand
Posts: 537
Eclipse IDE Python Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
THis is not a JDK malfunction. Its just not finding the class file that you are specifying in the java keyword
 
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
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.
 
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Also, don't install in "Program Files". May create problems.
 
Marshal
Posts: 80507
455
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
lowercase baba
Posts: 13091
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"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.
 
Campbell Ritchie
Marshal
Posts: 80507
455
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Marshal
Posts: 80507
455
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 \.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic