帮我解决这段代码,我得到运行时异常错误 java.lang.nullpointerexception 请帮助我解决这个问题以及如何使用 java 程序访问桌面上的任何文件,就像我想访问桌面上或桌面上的任何图像或文本文件一样任何其他折叠我应该写什么代码。仅供参考,我是菜鸟。
import java.io.*;
class jarvis
{
public static void main(String args[])
{
String i=null,j=null,k=null,l=null,m=null,n=null,o=null,a=null,q=null;
try
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.println("Command me: ");
if(i.equals("jarvis you there?"))
{
i=br.readLine();
System.out.println("at your service sir");
}
System.out.println("Command me: ");
if(j.equals("run command prompt"))
{
j=br.readLine();
Runtime r=Runtime.getRuntime();
Process p=r.exec("cmd.exe /c start");
}
System.out.println("Command me: ");
if(k.equals("run notepad"))
{
k=br.readLine();
Runtime r=Runtime.getRuntime();
Process p=r.exec("notepd.exe");
}
System.out.println("Command me: ");
if(l.equals("run paint"))
{
l=br.readLine();
Runtime r=Runtime.getRuntime();
Process p=r.exec("mspaint.exe");
}
System.out.println("Command me: ");
if(m.equals("open facebook"))
{
m=br.readLine();
Runtime r=Runtime.getRuntime();
Process p=r.exec("cmd.exe /c start www.facebook.com");
}
System.out.println("Command me: ");
if(n.equals("open google"))
{
n=br.readLine();
Runtime r=Runtime.getRuntime();
Process p=r.exec("cmd.exe /c start www.google.com");
}
System.out.println("Command me: ");
if(o.equals("open youtube"))
{
o=br.readLine();
Runtime r=Runtime.getRuntime();
Process p=r.exec("cmd.exe /c start www.youtube.com");
}
System.out.println("Command me: ");
if(a.equals("open yahoo"))
{
a=br.readLine();
Runtime r=Runtime.getRuntime();
Process p=r.exec("cmd.exe /c start www.yahoo.com");
}
System.out.println("Command me: ");
if(q.equals("open omegle"))
{
q=br.readLine();
Runtime r=Runtime.getRuntime();
Process p=r.exec("cmd.exe /c start www.omegle.com");
}
}
catch(Exception e)
{
System.out.print(e);
}
}
}