compile prog it gives error javac is not an internal or external command.but if i give the bin path it compile and gives error at run time Exception in main thread java.lang classnot found.
and if we save the prog in bin it compile and run successfully.why
I install the j2sdk in my computer and the java program save in the folder that is in the c drive .when we?
Beacuse the classpath is already set to your j2sdk/bin, if you compile and run this will work. But when you try to compile and run from other location defaultly the path may be set nor the classpath. that's why you get a runtime exception.
Reply:Yes, This is mainly do a an 'Environment Variable' not being set. To do this, do the following
- Choose Start, Settings, Control Panel, and double-click System. On Microsoft Windows NT, select the Environment tab; on Microsoft Windows 2000 select the Advanced tab and then Environment Variables.
- Look for "Classpath" in the System Variables . If you're not sure where to add the path, add it to the right end of the "Path" in the User Variables. A typical value for CLASSPATH is:
C:\Program Files\Java\jdk1.5.0_%26lt;version%26gt;\bin
(NOte: Capitalization doesn't matter.)
- Make sure you add a dot (.) preceded by a semicolon to the above; the result in the above line should look like this after you make the amendment.
C:\Program Files\Java\jdk1.5.0_%26lt;version%26gt;\bin;.
(without this step, you still will have the same problem)
- Click "Set", "OK" or "Apply".
Reply:u must specify the complete path of ur .java code and then when u run the program u have also to specify the complete path again
javac completepath\yourprogram.java
java completepath\yourpragrammainclass.class
Reply:You need to set the classpath. Please read the documentation that comes along with it. It describes how to set the path and classpath.
land survey
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment