在Java中,我需要运行一个本地方法(下面的代码)

在Java中,我需要运行一个本地方法(下面的代码),java,class,methods,Java,Class,Methods,嘿,我一直试图让main运行这些方法,但我不记得怎么做了。 到目前为止,这是一个简单的程序,因为我15分钟前才开始 ` `justbrowserJacker(1)可以,我希望你没有恶意。 import java.awt.Robot; import javax.swing.JFrame; import java.lang.*; import java.io.*; public class sweetRevenge { public static void main(String[] args)

嘿,我一直试图让main运行这些方法,但我不记得怎么做了。 到目前为止,这是一个简单的程序,因为我15分钟前才开始

`


`

just
browserJacker(1)可以,我希望你没有恶意。
import java.awt.Robot;
import javax.swing.JFrame;
import java.lang.*;
import java.io.*;
public class sweetRevenge {

public static void main(String[] args) {
//call local static classes browserjacker and wallpaperjacker
   start(browserJacker(1));




   } 


   public static void browserJacker(int i)throws IOException{
 try
 { 
//include bad things along with self made video of hacking linked to youtube
 Process p=Runtime.getRuntime().exec("cmd /c start http://www.google.com"); 
 } 
 catch(IOException e1) {System.out.println(e1);} 

 }
 public static void wallpaperJacker (String args []) throws IOException {
Process p=Runtime.getRuntime().exec("cmd /c start");
  }}
since your method is throwing an exception so the place where you will call it MUST have an exception handling mechanism, and your code needs to be modified.

import java.awt.Robot;
import javax.swing.JFrame;
import java.lang.*;
import java.io.*;
public class sweetRevenge {

public static void main(String[] args) {
//call local static classes browserjacker and wallpaperjacker

   try{
     browserJacker(); // will start method browserJacker
     // since the method is static so it can be easily accessed from static method
   }catch{IOException ex}{
   }

} 

public static void browserJacker()throws IOException{
   //include bad things along with self made video of hacking linked to youtube
   Process p=Runtime.getRuntime().exec("cmd /c start http://www.google.com"); 
}

 public static void wallpaperJacker () throws IOException {
   Process p=Runtime.getRuntime().exec("cmd /c start");
     }
}