How to save and run a Java file in PuTTY?

半世苍凉 提交于 2019-12-01 13:20:26

I am using putty since almost 2 years..

U should open the vi editor using "vi filename.java"

Type the program and then say "Esc : wq" ignore the spaces.. And Esc is the Esc button on keyboard..

Then compile your program using "javac filename.java"

N then run using java filename.java

See Saumil..

When you login then the directory in which you are landed is your users home directory.. Like in your case "ec2-user"..

So if you do "vi filename" without changing directory then the file is created in the users home directory "/home/ec2-user" .. N that is represented by ~.. Which represents the current users home directory..

N then if you logout and login again then the file stays there.. Nothing happens to that file as long as you manually delete it..

N by the above snapshot I can see that after login you are changing your user to root.. But if you could see after doing sudo you still remain in the same directory. N "~" changes to "ec2-user" because the root users home directory is different..

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!