【问题标题】:In Java I need to run a local method (code below)在Java中我需要运行一个本地方法(下面的代码)
【发布时间】:2013-04-13 03:22:47
【问题描述】:

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

`

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");
  }}

`

【问题讨论】:

  • 只要browserJacker(1);就可以了
  • 我希望你不打算做任何恶意的事情。

标签: java class methods


【解决方案1】:
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");
     }
}

【讨论】:

    猜你喜欢
    • 2020-02-14
    • 1970-01-01
    • 1970-01-01
    • 2019-07-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-05-28
    相关资源
    最近更新 更多