Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: 1.7 JRE library error?

  1. #1
    Junior Member
    Join Date
    Oct 2011
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default 1.7 JRE library error?

    Hi everyone, I'm quite new to programming and have come across an error in my program that is throwing me for a loop. I've tested the code on a friend's computer and it worked but when I copy and pasted it onto my laptop suddenly my switch line is giving me an error code that says " Cannot switch on a value of type String for source level below 1.7" I went online and downloaded a 64bit 1.7 library and when I switched the library over suddenly error codes were appearing everywhere. Here is my code and any help would be greatly appreciated! Thanks in advance everyone and please don't be too harsh if I ask seemingly stupid questions. I've only been at programming for a couple weeks.

    import java.io.BufferedReader;
    import java.io.FileReader;

    public class calculator {


    static int a = 0;
    static int b; //this is the first term
    static int c; //this is the second term
    static int d; //this is my final answers


    public static void main(String args[]) throws Exception{

    FileReader cats = new FileReader("File's Address");
    BufferedReader dogs = new BufferedReader(cats);
    String fish;

    while((fish = dogs.readLine()) != null){
    String[] variabizzles = fish.split(" ");
    a++;

    b = Integer.parseInt(variabizzles[0]);
    String operator = variabizzles[1];
    c = Integer.parseInt(variabizzles[2]);

    switch(variabizzles[1]){

    case "+": d = b + c;
    break;
    case "-": d = b - c; //This was a much better plan than the fail IF/ELSE statements.
    break;
    case "/": d = b / c;
    break;
    case "*": d = b * c;


    }


    System.out.println("Problem " + a + ": " + b + operator + c + "=" + d);

    }
    }
    }


  2. #2
    Forum VIP
    Join Date
    Oct 2010
    Posts
    275
    My Mood
    Cool
    Thanks
    32
    Thanked 54 Times in 47 Posts
    Blog Entries
    2

    Default Re: 1.7 JRE library error?

    Please highlight your code

    BBCode Tutorial
    Specifically
    Highlight Tags

    Except instead of just

    [highlight]**Code**[/highlight]

    do

    [highlight=Java]**Code**[/highlight]


    As for the error, update java. Ok re-read your paragrash about 5 times, you need to uninstall and reinstall, and see if that works.

    For removing the older version, look here
    Last edited by Tjstretch; October 26th, 2011 at 11:46 PM.

  3. #3
    Junior Member
    Join Date
    Oct 2011
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: 1.7 JRE library error?

    import java.io.BufferedReader;
    import java.io.FileReader;

    public class calculator {


    static int a = 0;
    static int b; //this is the first term
    static int c; //this is the second term
    static int d; //this is my final answers


    public static void main(String args[]) throws Exception{

    FileReader cats = new FileReader("File's Address");
    BufferedReader dogs = new BufferedReader(cats);
    String fish;

    while((fish = dogs.readLine()) != null){
    String[] variables = fish.split(" ");
    a++;

    b = Integer.parseInt(variables[0]);
    String operator = variables[1];
    c = Integer.parseInt(variables[2]);

    switch(variables[1]){

    case "+": d = b + c;
    break;
    case "-": d = b -c; //This was a much better plan than the fail IF/ELSE statements.
    break;
    case "/": d = b / c;
    break;
    case "*": d = b * c;


    }


    System.out.println("Problem " + a + ": " + b + operator + c + "=" + d);

    }
    }
    }

  4. #4
    Junior Member
    Join Date
    Jul 2011
    Posts
    17
    Thanks
    0
    Thanked 4 Times in 4 Posts

    Default Re: 1.7 JRE library error?

    i think u must right click on your project --> properties --> in sources change source/binary format to jdk 1.7 --> in libaries java platform to 1.7

Similar Threads

  1. Where to place my own library?
    By hexwind in forum Java Theory & Questions
    Replies: 3
    Last Post: June 22nd, 2011, 07:25 AM
  2. how to use SteelSeries library?
    By aang in forum What's Wrong With My Code?
    Replies: 1
    Last Post: November 22nd, 2010, 12:57 PM
  3. Grid GUI Library
    By aussiemcgr in forum Java Theory & Questions
    Replies: 7
    Last Post: September 15th, 2010, 04:30 PM
  4. Powerpoint Library
    By aussiemcgr in forum Java Theory & Questions
    Replies: 0
    Last Post: July 22nd, 2010, 09:26 AM
  5. library
    By b109 in forum Java Theory & Questions
    Replies: 2
    Last Post: May 3rd, 2010, 06:32 AM