Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't switch to compiler compliance level 1.8 in Eclipse Helios

I am pretty new to eclipse and programming,Currently i am trying to learn java from a tutorial from caveofprogramming.com When i was trying to follow one tutorial based on switch an error keep disturbing me.

import java.util.Scanner;

 public class App{

public static void main(String[] args){

 Scanner input = new Scanner(System.in);

 System.out.println("enter a number");

 String text = input.nextLine();

 switch(text) {

 case "start";

 System.out.println("Machine started");

 break; }  }   }

And it gives me an error on the switch command saying:

cannot switch on a value of type string. only int values or enum constants are permitted

John Purcell at caveofprogramming.com suggested that its because of the compiler compliance level which is currently 1.4 and he said me to switch that to 1.8 but its not available there.1.6 is the last level which i can use.

like image 598
nihaljp Avatar asked Dec 08 '25 05:12

nihaljp


1 Answers

Download and install the current Eclipse version. Eclipse has a build-in Java compiler. Switching on Strings was added in Java SE 1.7. Java SE 1.4 is a very old version of Java. It's not a good idea to learn programming using a version of Java which is that old.

Also, as the other answer suggests, install the latest JDK.

like image 171
Alexey Avatar answered Dec 10 '25 18:12

Alexey



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!