Java code works on Mac, but on non-PC

2

The following code works on my Mac and not on the pc. I really need to start working on the pc, so I appreciate any help I can get. I'm using Eclipse Java Oxygen on both platforms.

Code:

import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.PrintWriter;

public class coordinates {

public static void main(String[] args) {

   try {

       BufferedReader in = new BufferedReader(new FileReader(new File("C:\Users\TelmoG\Desktop\06092017.txt")));
       PrintWriter out = new PrintWriter("C:\Users\TelmoG\Desktop\outputFile.csv");

       String newLine ="";
       int index = 0;
       String line = "";

       while((line = in.readLine()) != null){
          // System.out.println(line);
           index++;

           if (index %2 == 0){
               newLine += ";" + line.substring(34);
               out.println(newLine);
           } else {
               newLine = line.substring(34);
           };  
       } 
       in.close();
       out.close();

        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
    }      
 }
 }

Error:

  

Exception in thread "main" java.lang.Error: Unresolved compilation   problem:

     

at coordinates.coordinates.main (coordinates.java:25)

     

Line 25:

     

public static void main (String [] args) {

    
asked by anonymous 27.09.2017 / 11:07

1 answer

5

This is due to a compile error - in eclipse it should say which error - check the View "Problems" or the left annotation of the panel with the code, probably in the first line of the code and eventually with the following message:

  

The declared package "" does not match the expected package "coordinates"

For the code you posted, or the package statement is missing:

package coordinates;

or the coordinates.java file is in the wrong directory: move to the parent directory of coordinates (or the Eclipse project has Source folder wrong).

    
27.09.2017 / 12:38