-1

I have a maven java project in eclipse. I added a groovy file in the project having a public variable. I access the groovy variable in another java class but i get compilation error (see below). I have the GRECLIPSE plugin installed. Also via command line when I build the project using mvn it compiles successfully.

How do I resolve this?

Groovy class -

package com.impl

class UserConstants {
    public static final String USER_PREFERENCES = 
        """Some value"""
}

Java class in the same package. At the import line I get error "The import cannot be resolved" and due to that I get error at the Sysout line also "USER_PREFERENCES cannot be resolved to a variable"

package com.impl

import static com.impl.UserConstants.USER_PREFERENCES;

public class UserPreferences {
    public UserPreferences() {
        System.out.println(USER_PREFERENCES);
    }
}
Sharad Yadav
  • 2,951
  • 5
  • 20
  • 18

1 Answers1

0

Converting the project into Groovy project solved the problem

Sharad Yadav
  • 2,951
  • 5
  • 20
  • 18