• 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

Error: Could not find or load main class com.sun.tools.javac.Main

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So, i'm trying to compile HelloWorldApp.java

I installed Java on my flashdrive(i dont think that should be a problem) - H:\java
I have my Path set to H:\Java\bin;
I see that the javac.exe is installed in the bin, but when on command prompt i try "javac -version" it still says
"Error: Could not find or load main class com.sun.tools.javac.Main"

Any idea what i'm doing wrong? Please help, not being able to compile anything is getting annoying.

Thanks,
God Bless you
 
Ranch Hand
Posts: 147
Eclipse IDE Tomcat Server Debian
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It sounds like you're either missing part of the JDK (tools.jar) or your classpath is not set up correctly. javac.exe is really just a wrapper that fires com.sun.tools.javac.Main from that tools.jar in JDK_HOME/lib.

When you copied it to your flash drive, did you copy everything?
 
John Simer
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I believe I installed it to the H: drive and never copied anything
 
Marshal
Posts: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
H:\java\bin

That doesn’t sound right. It usually has something like jdk1.7.0_00 after “Java” and before “bin”. Open that folder with Windows® Explorer and check what the correct path to your bin folder is.
 
John Simer
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My bin folder is saved inside of my Java folder
 
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Campbell Ritchie wrote:H:\java\bin

That doesn’t sound right. It usually has something like jdk1.7.0_00 after “Java” and before “bin”. Open that folder with Windows® Explorer and check what the correct path to your bin folder is.


Don't forget you can change the path during installation. On my system I have changed the defaults to D:\Programs\JDK\1.6.0 and D:\Programs\JDK\1.7.0 (with D: being my Development drive).
 
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

John Simer wrote:My bin folder is saved inside of my Java folder

In that case the path would be correct. Have you got all the other parts of the JRE, eg rt.jar, in that Java folder in such a location that their relative path would be the same as in an installation to yoru hard drive? On my hard drive, the jre and bin folders are both immediate subfolders of jdk1.7.0_01, and rt.jar is inside the jre folder, so rt.jar and the “java” tool are in folders which share the same “grandparent” folder, viz jdk1.7.0_01.
 
John Simer
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok I just decided to delete java off my flashdrive(H:) and save it on my computer (C:), and I got the compiling part to work, but in a weird way. I had to go to where the javac.exe and from there type the javac command for the entire file name like this:

"C:\Program Files\Java\jdk1.7.0_02\bin>javac C:\jvj\HelloWorldApp\HelloWorldApp.j ava"

then the .class showed up in my directory

Directory of C:\jvj\HelloWorldApp

12/20/2011 01:43 PM <DIR> .
12/20/2011 01:43 PM <DIR> ..
12/20/2011 01:43 PM 432 HelloWorldApp.class
12/20/2011 01:43 PM 118 HelloWorldApp.java
2 File(s) 550 bytes
2 Dir(s) 74,377,527,296 bytes free


but when i tried running it...

C:\jvj\HelloWorldApp>java HelloWorldApp.class
Error: loading: H:\Java\bin\client\jvm.dll

^why is it still trying to get stuff from my flashdrive? It should be trying to get the files from C:\Program Files\Java\jre6\bin
 
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
Why would you expect to use files in a jre6 folder when you are using “javac” in a jdk7 folder?
 
John Simer
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm not really sure... Because i'm using the "java" and not the "javac", so isnt the "java" just running it?

But regardless how do I make it work? (i.e. when i use the java.exe it runs the program)
 
John Simer
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok basically I reinstalled java again this time version 6u29 instead of 7u2, and i got the javac to work
"C:\Program Files\Java\jdk1.6.0_30\bin>javac C:\jvj\HelloWorldApp\HelloWorldApp.j
ava

C:\Program Files\Java\jdk1.6.0_30\bin>cd\jvj\HelloWorldApp

C:\jvj\HelloWorldApp>dir
Volume in drive C is ACER
Volume Serial Number is A057-D808

Directory of C:\jvj\HelloWorldApp

12/20/2011 08:48 PM <DIR> .
12/20/2011 08:48 PM <DIR> ..
12/20/2011 09:00 PM 432 HelloWorldApp.class
12/20/2011 01:43 PM 118 HelloWorldApp.java
2 File(s) 550 bytes
2 Dir(s) 75,082,752,000 bytes free"
but running it still doesnt work.
"C:\jvj\HelloWorldApp>java HelloWorldApp
'java' is not recognized as an internal or external command,
operable program or batch file."

likewise,
"C:\jvj\HelloWorldApp>java -cp . HelloWorldApp
'java' is not recognized as an internal or external command,
operable program or batch file."
and,
"C:\jvj\HelloWorldApp>java -classpath . HelloWorldApp
'java' is not recognized as an internal or external command,
operable program or batch file."



EDIT: --------------
i made a new topic that now there is a different problem
Thanks for all the help guys!
Jesus Christ is truly amazing!
 
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
That is the usual place to install Java™. You can probably install Java™ to your flash stick by altering the options when you install it, but you would need a different path. There is information about setting paths, etc, in our FAQ.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic