简体   繁体   中英

How do I develop on a virtual machine using Eclipse?

I have a project that I built on my virtual machine using sbt. During the build process it installs several libraries in the ~/root/ directory in my virtual machine. For example, part of the .classpath file looks like:

<classpathentry kind="lib" path="/root/.ivy2/cache/org.apache.avro/avro/jars/avro-1.7.6.jar"/>
<classpathentry kind="lib" path="/root/.ivy2/cache/org.codehaus.jackson/jackson-core-asl/jars/jackson-core-asl-1.9.13.jar"/>
<classpathentry kind="lib" path="/root/.ivy2/cache/org.codehaus.jackson/jackson-mapper-asl/jars/jackson-mapper-asl-1.9.13.jar"/>
<classpathentry kind="lib" path="/root/.ivy2/cache/org.apache.commons/commons-compress/jars/commons-compress-1.4.1.jar"/>

I am running Eclipse on my Mac OS on the host machine and when I import an Eclipse project (through a samba mount) I end up with a bunch of import errors because the class paths are only valid on my guest machine.

What is the typical / standard way to develop Java / Scala projects within a virtual environment while running the Eclipse application from your host machine?

Am I better off doing all the development on my host machine?

This is not necessary a typical or standard solution to the above problem. However, it solved my specific issue when using sbt-eclipse plugin to generate the project files.

Turns out you can pass in a relative path to the sbt-eclipse plugin and that will propagate to the .classpath file.

./sbt eclipse -ivy ./ivy

That way when you import the project into Eclipse it will use all of the relative paths based on the root project path. It seems to work so far.

<classpathentry kind="lib" path="./ivy/cache/org.apache.avro/avro-compiler/bundles/avro-compiler-1.7.6.jar"/>
<classpathentry kind="lib" path="./ivy/cache/org.apache.avro/avro/bundles/avro-1.7.6.jar"/>
<classpathentry kind="lib" path="./ivy/cache/org.codehaus.jackson/jackson-core-asl/jars/jackson-core-asl-1.9.13.jar"/>
<classpathentry kind="lib" path="./ivy/cache/org.codehaus.jackson/jackson-mapper-asl/jars/jackson-mapper-asl-1.9.13.jar"/>
<classpathentry kind="lib" path="./ivy/cache/org.apache.commons/commons-compress/jars/commons-compress-1.4.1.jar"/>

Note that while this solves the import errors, the application is still being run on the host machine instead of the virtual machine.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM