通过Netbeans编译,不通过CMD编译

时间:2017-05-08 17:38:19

标签: javascript java storage

我有我的代码来处理存储管理 页面替换方法分配。我的代码通过Netbeans工作,但它不能通过CMD编译。

你知道为什么吗?

public class Paging {

/**
 * @param args the command line arguments
 */
public static void main(String[] args) throws IOException, IOException, IOException, IOException {

    BufferedReader obj = new BufferedReader(new InputStreamReader(System.in));

     try {
    URL url = new URL("www.csc.liv.ac.uk/~ped/COMP104/COMP104-2016-17/Page_Trace_Oldest");       

    URL url3 = new URL("www.csc.liv.ac.uk/~ped/COMP104/COMP104-2016-17/Page_Trace_Random");

    BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
    String str;
    while ((str = in.readLine()) != null) {
        str = in.readLine().toString();
        System.out.println(str);
     }
    in.close();
} catch (MalformedURLException e) {
} catch (IOException e) {
}
     URL url2 = new URL("www.csc.liv.ac.uk/~ped/COMP104/COMP104-2016-17/Page_Trace_LRU");
     BufferedReader in = new BufferedReader(new InputStreamReader(url2.openStream()));
    String str2;
    while ((str2 = in.readLine()) != null) {
        str2 = in.readLine().toString();
        System.out.println(str2);
     }
    in.close();

    URL url3 = new URL("www.csc.liv.ac.uk/~ped/COMP104/COMP104-2016-17/Page_Trace_Random");
     BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
    String str3;
    while ((str3 = in.readLine()) != null) {
        str2 = in.readLine().toString();
        System.out.println(str3);
     }
    in.close();



    int f, page = 0, ch, pgf = 0, n = 0, chn = 0;

    boolean flag;
    int pages[];
    do {

        System.out.println("Menu");
        System.out.println("1.FIFO");
        System.out.println("2.LRU");

        System.out.println("3.LFU");

        System.out.println("4.EXIT");

        System.out.println("ENTER YOUR CHOICE: ");

        try {
            ch = Integer.parseInt(obj.readLine());
        } catch (IOException ex) {
            Logger.getLogger(Paging.class.getName()).log(Level.SEVERE, null, ex);
        }

        switch (ch) {

            case 1:

                int pt = 0;

                System.out.println("Enter no. of frames (1-8): ");

                f = Integer.parseInt(obj.readLine());

                int frame[] = new int[f];

                for (int i = 0; i < f; i++) {

                    frame[i] = -1;

                }

                System.out.println("enter the no of pages ");

                n = Integer.parseInt(obj.readLine());

                pages = new int[n];

                System.out.println("enter the page no ");

                for (int j = 0; j < n; j++) {
                    pages[j] = Integer.parseInt(obj.readLine());
                }

                do {

                    int pg = 0;

                    for (pg = 0; pg < n; pg++) {

                        page = pages[pg];

                        flag = true;

                        for (int j = 0; j < f; j++) {

                            if (page == frame[j]) {

                                flag = false;

                                break;

                            }

                        }

                        if (flag) {

                            frame[pt] = page;

                            pt++;

                            if (pt == f) {
                                pt = 0;
                            }

                            System.out.print("frame :");

                            for (int j = 0; j < f; j++) {
                                System.out.print(frame[j] + "   ");
                            }

                            System.out.println();

                            pgf++;

                        } else {

                            System.out.print("frame :");

                            for (int j = 0; j < f; j++) {
                                System.out.print(frame[j] + "  ");
                            }

                            System.out.println();

                        }

                        chn++;

                    }

                } while (chn != n);

                System.out.println("Page fault:" + pgf);

                break;

            case 2:

                int k = 0;

                System.out.println("enter no. of frames: ");

        {
            try {
                f = Integer.parseInt(obj.readLine());
            } catch (IOException ex) {
                Logger.getLogger(Paging.class.getName()).log(Level.SEVERE, null, ex);
            }
        }

                int frame1[] = new int[f];

                int a[] = new int[f];

                int b[] = new int[f];

                for (int i = 0; i < f; i++) {

                    frame1[i] = -1;

                    a[i] = -1;

                    b[i] = -1;

                }

                System.out.println("enter the no of pages ");

        {
            try {
                n = Integer.parseInt(obj.readLine());
            } catch (IOException ex) {
                Logger.getLogger(Paging.class.getName()).log(Level.SEVERE, null, ex);
            }
        }

                pages = new int[n];

                System.out.println("enter the page no ");

                for (int j = 0; j < n; j++) {
            try {
                pages[j] = Integer.parseInt(obj.readLine());
            } catch (IOException ex) {
                Logger.getLogger(Paging.class.getName()).log(Level.SEVERE, null, ex);
            }
                }

                do {

                    int pg = 0;

                    for (pg = 0; pg < n; pg++) {

                        page = pages[pg];

                        flag = true;

                        for (int j = 0; j < f; j++) {

                            if (page == frame1[j]) {
                                flag = false;
                                break;
                            }

                        }

                        for (int j = 0; j < f && flag; j++) {

                            if (frame1[j] == a[f - 1]) {
                                k = j;

                                break;
                            }

                        }

                        if (flag) {

                            frame1[k] = page;

                            System.out.println("frame :");

                            for (int j = 0; j < f; j++) {
                                System.out.print(frame1[j] + "  ");
                            }

                            pgf++;

                            System.out.println();

                        } else {

                            System.out.println("frame :");

                            for (int j = 0; j < f; j++) {
                                System.out.print(frame1[j] + "  ");
                            }

                            System.out.println();

                        }

                        int p = 1;

                        b[0] = page;

                        for (int j = 0; j < a.length; j++) {

                            if (page != a[j] && p < f) {

                                b[p] = a[j];

                                p++;

                            }

                        }

                        for (int j = 0; j < f; j++) {

                            a[j] = b[j];

                        }

                        chn++;

                    }

                } while (chn != n);

                System.out.println("Page fault:" + pgf);

                break;

            case 3:

                k = 0;

                pgf = 0;

                int sml;

                System.out.println("enter no. of frames: ");

        {
            try {
                f = Integer.parseInt(obj.readLine());
            } catch (IOException ex) {
                Logger.getLogger(Paging.class.getName()).log(Level.SEVERE, null, ex);
            }
        }

                int frame2[] = new int[f];

                int cnt[] = new int[f];

                flag = true;

                for (int i = 0; i < f; i++) {

                    frame2[i] = -1;

                    cnt[i] = 0;

                }

                System.out.println("enter the no of pages ");

        {
            try {
                n = Integer.parseInt(obj.readLine());
            } catch (IOException ex) {
                Logger.getLogger(Paging.class.getName()).log(Level.SEVERE, null, ex);
            }
        }

                pages = new int[n];

                System.out.println("enter the page no ");

                for (int j = 0; j < n; j++) {
            try {
                pages[j] = Integer.parseInt(obj.readLine());
            } catch (IOException ex) {
                Logger.getLogger(Paging.class.getName()).log(Level.SEVERE, null, ex);
            }
                }

                do {

                    int pg = 0;

                    for (pg = 0; pg < n; pg++) {

                        page = pages[pg];

                        flag = true;

                        for (int j = 0; j < f; j++) {

                            if (page == frame2[j]) {

                                flag = false;

                                cnt[j]++;

                                break;

                            }

                        }

                        if (flag) {

                            sml = cnt[0];

                            for (int j = 0; j < f; j++) {

                                if (cnt[j] < sml) {

                                    sml = cnt[j];

                                    break;

                                }

                            }

                            for (int j = 0; j < f; j++) {

                                if (sml == cnt[j]) {

                                    frame2[j] = page;

                                    k = j;

                                    break;

                                }

                            }

                            cnt[k] = 1;

                            System.out.print("frame :");

                            for (int j = 0; j < f; j++) {

                                System.out.print(frame2[j] + "   ");

                                System.out.println();

                                pgf++;

                            }

                        } else {

                            System.out.print("frame :");

                            for (int j = 0; j < f; j++) {
                                System.out.print(frame2[j] + "  ");
                            }

                            System.out.println();

                        }

                        chn++;

                    }

                } while (chn != n);

                System.out.println("Page fault:" + pgf);

                break;

            case 4:

                break;

        }

    } while (ch != 4);
}

}

我得到的错误是:Error message

1 个答案:

答案 0 :(得分:1)

您正在创建2个具有相同名称的BufferedReader对象。

GtkToolItem*

URL url2 = new URL("www.csc.liv.ac.uk/~ped/COMP104/COMP104-2016-17/Page_Trace_LRU");
BufferedReader in = new BufferedReader(new InputStreamReader(url2.openStream()));