问题
I have an existing Java project that I created using Eclipse on a different computer and uploaded to github. On my Fedora machine, I used Anjuta's github plugin to import the project and the import worked fine (I can see all my java files in the Project pane).
However, when I click Run -> Execute I get the following errors:
/home/bhavesh/AnjutaProjects/word_wave.git/deltaHacks/src/deltaHacks/LeapFun.java: line 1: package: command not found
/home/bhavesh/AnjutaProjects/word_wave.git/deltaHacks/src/deltaHacks/LeapFun.java: line 2: import: command not found
/home/bhavesh/AnjutaProjects/word_wave.git/deltaHacks/src/deltaHacks/LeapFun.java: line 3: import: command not found
/home/bhavesh/AnjutaProjects/word_wave.git/deltaHacks/src/deltaHacks/LeapFun.java: line 5: public: command not found
/home/bhavesh/AnjutaProjects/word_wave.git/deltaHacks/src/deltaHacks/LeapFun.java: line 7: syntax error near unexpected token `('
/home/bhavesh/AnjutaProjects/word_wave.git/deltaHacks/src/deltaHacks/LeapFun.java: line 7: ` public static void main(String[] args) {'
It seems that Anjuta doesn't recognize this project as a Java project. What setting should I change to make it recognize the Java?
回答1:
It's not that easy - Eclipse has (maybe hidden) files which contain the dependencies between the modules, and how each file has to be treated. I doubt that anjuta imports that information.
So, it might be necessary to define a project, make the .java files part of that project. Then hit compile.
The fact anjuta is trying to execute a source file, is probably because in the 'run' options, the executable is set to that java file.
来源:https://stackoverflow.com/questions/28617645/how-to-import-an-existing-java-project-in-the-anjuta-ide