This week's book giveaway is in the General Computing forum. We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line! See this thread for details.
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.
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?
OCPJP
In preparing for battle I have always found that plans are useless, but planning is indispensable. -- Dwight D. Eisenhower
John Simer
Greenhorn
Joined: Dec 19, 2011
Posts: 16
posted
0
I believe I installed it to the H: drive and never copied anything
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.
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).
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
Joined: Dec 19, 2011
Posts: 16
posted
0
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:
^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
Sheriff
Joined: Oct 13, 2005
Posts: 32827
4
posted
0
Why would you expect to use files in a jre6 folder when you are using “javac” in a jdk7 folder?
John Simer
Greenhorn
Joined: Dec 19, 2011
Posts: 16
posted
0
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
Joined: Dec 19, 2011
Posts: 16
posted
0
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:\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
Sheriff
Joined: Oct 13, 2005
Posts: 32827
4
posted
0
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.