Thursday, July 30, 2009

Need Help from someone who knows programming well. PLEASE!!!!?

in our class we were asked to compile and run a simple java program. we use JDK 1.5, Notepad and the command prompt. we were asked to install jdk 1.5 and then create a path.


it should be typed in a notepad document as,


path "C;\programmefiles\java\jdk1.5\bin" and save in "C" as "mypath.bat.





After doing so we were ordered to run the program below in DOS but have to type in notepad.





class Sum{


int x = 10, y = 20;


int total = x + y;





public static void main (String asgs[]) {


System.out.println (total);


}


}





and save as sum.java





after doing everything above i have to go to command prompt and go to "C" and type "mypath". Then it sould compile there and give the out put. But in my case the program compiles, but i don't get the out put (the answer). Please help.

Need Help from someone who knows programming well. PLEASE!!!!?
rather creating the path as mypath .bat you can do this easy way(easy for me :) )


1....right click the MY COMPUTER


2.... select properties from that menu


3....in the newly opened window click the advanced tab at the top


4....now click envioronment variables at the bottom


5....in the newly opened dialog window and in the system variables sub- window at the bottom search for PATH and double click it ( a new small window will open)


6....now open your JDK bin folder in an explorer , perhaps in your case it will be as you have given as





C:\programmefiles\java\jdk1.5\bin..





or jus copy the path from the address bar of the explorer(perhaps it will be as the above path)


7....now paste that path in the VARIABLE VALUE of the newly opened small window ( if there is not a " ; " (semi-colon) at the end of the variable value then append it , then paste the path there and append a " ; " )


9....click ok .. then ok... then ok....





thats it !!





do this first .... the way you have given above looks weird to me (but there may be a way alike )


Look for other answers , then try the above mentioned way of setting the PATH variable ...





now open the command prompt ....


then go to the path where you have saved the SUM.java file





now type this ... javac sum.java then press enter


..


you will get errors , if not now your programme has compiled succesfully,





then type this to run your program





java Sum .... press enter (here Sum is the class name)





you must now get 30 as your output !











is that this you expected ! still you have problems try adding more info to your question, or mail me your problem (gmaran23@yahoo.com)





the above mentioned way is the most appropriate way of setting the path variable !


No comments:

Post a Comment