-1

I installed eclipse on Ubuntu 16.04 but this code

public class WhileCounter
{
     public static void main ( String [] args)
  {
    int counter = 1;

    while (counter <= 10)
    {
        System.out.printf("%d", counter);
        ++counter;
    }

    System.out.println();
   }
 }

I'm getting this error

The method printf(String, Object[]) in the type PrintStream is not applicable for the arguments (String, int)

and a warning

Build path specifies execution environment OSGi/Minimum-1.2. There are no JREs installed in the workspace that are strictly compatible with this environment.

So I remove open jdk by this command sudo apt-get purge openjdk-\* and use this to install oracle jdk apt-get install oracle-java8-installer but the problem still exist.

CatCoder
  • 248
  • 2
  • 10

1 Answers1

0

I fix warning by doing

  1. Right-click on your project
  2. Click Properties
  3. Java build path: Libraries; Remove the "JRE System Library[J2SE 1.4]"
  4. Click Add Library -> JRE System Library
  5. Select the new "Execution Environment" or Workspace default JRE

    and error by doing :

Check that the Compiler compliance level is set to at least 1.5 for your project: Project > Properties > Java Compiler and set compiler compliance level to 1.7

CatCoder
  • 248
  • 2
  • 10