1

I think I'm making a simple mistake here, but I can't get Frege to find any classes outside of the local Eclipse project.

I have a working non-trivial Java project (that's not mine), that I do not want to modify. I want to have a new clean Frege enabled project that makes use of classes from the original project.

I tried marking the original project as a dependency of my Frege project, and I tried packaging the original project into a JAR, and listing the JAR as an external dependency of the Frege project. In both cases, a Java file in the Frege project can access the classes, but the Frege compiler says "class org.foo.bar.Class is not a known Java class". This seems like a bug, but I am not confident that I have not missed a simple configuration step.

I have not tried setting arguments in the project configuration as I wouldn't know what to set.

I did quickly discover that I can make a new Java file in the Frege project with a blank subclass of whatever class I need and use that in a Frege file. I have successfully compiled and run a simple program like this. The program just makes a new object, gets a field, and prints the correct value, so I believe my Frege is installed and working properly.

More info:

  • Eclipse Luna 4.4.0
  • Java 7
  • No Maven
  • Official eclipse-ferge plugin installed through Eclipse
parker.sikand
  • 1,371
  • 2
  • 15
  • 32
  • 1
    Is it a maven based project? is your setup has the right java versions? https://github.com/Frege/frege/wiki/Getting-Started . did you use https://github.com/Frege/eclipse-plugin? – Syed Ekram Uddin May 07 '16 at 18:26
  • no maven. yes eclipse-plugin. I have it set to use Java 7 and I am sure the Java classes do not use any newer Java features. These classes are simple, but there are many. – parker.sikand May 07 '16 at 19:08
  • 1
    Im can guess 2 suspects, one is to the parent project has dependency in ferge project with forge .jar like this https://github.com/Frege/frege/wiki/Frequently-Asked-Questions#can-i-make-a-stand-alone-frege-application-jar and that not build with the parent jar. or you might not add dependency with your current project? another is eclipse might get confused as says in https://github.com/Frege/frege/wiki/Frequently-Asked-Questions#can-i-hack-the-compilerlibrary-in-eclipse – Syed Ekram Uddin May 07 '16 at 19:23
  • Ok I'm getting odd behavior now. I am referencing the JAR as an external dependency. In my ferge module where I write a `data` type for my external class, I get the unknown class error. However, my main ferge module compiles and runs correctly, even though my other module file is marked with errors. I am getting the behavior that I want, even though the compiler is detecting errors. I am not sure why I am allowed to build and run my project like this, but this is acceptable to me for now. – parker.sikand May 07 '16 at 20:16
  • 2
    Maybe restart the eclipse with clean would be a nice try. sometime editors get lost their capacity and behave incorrectly. it happens in netbeans as well. if you think these comments would others then vote it so others gets use of it. Or do you think we need to compile all comments in an answer? – Syed Ekram Uddin May 07 '16 at 20:42
  • 1
    Not sure about an answer yet. I need to play around with this more and see if I can make the errors go away. – parker.sikand May 07 '16 at 20:53
  • Also I was thinking since the build is successful, It could be reason for what frege says in their far regardin eclipse confusion. I recently switch netbeans from eclipse and I think netbeans getting better day by day. – Syed Ekram Uddin May 08 '16 at 05:30

1 Answers1

2

It should be enough to have your library listed in the build path and under "Referenced Libraries". Your recent comment indicates that the compiler does indeed find the class in question.

However, when you have an open editor tab it will not take notice of changed dependencies. Also, especially in recent eclipse versions I have observed that resolved error markers are sometimes not cleaned up correctly.

Please close the editor tab that has the false errors shown, and reopen it.

Ingo
  • 36,037
  • 5
  • 53
  • 100
  • Ok so this works if I use the JAR. However, I would rather name the project as a dependency, so I don't need to rebuild the JAR if I start tweaking some classes. When I try it that way, I now get an error saying that the Frege builder failed in a file in the other project, in one of the classes I want to use. So that seems like progress but the error is not very helpful. The other project is very plain Java. – parker.sikand May 07 '16 at 23:41
  • It could also be the bin/ directory of the other project, I guess. This way, your Frege project would always consume the most recent state. – Ingo May 08 '16 at 08:27