How to port an Eclipse Java project to another PC and compile it from Shell? -


i have created java project in eclipse , executed directly eclipse on windows pc. have run same java program on linux server.

i have tried copy .class files pc server , run didn't work. after copied whole project , run javac myproject.java shell , returned following errors:

recordimportbatch.java:2: error: package org.apache.commons.io not exist import org.apache.commons.io.fileutils;  ...  recordimportbatch.java:3: error: package org.neo4j.graphdb not exist import org.neo4j.graphdb.relationshiptype; 

which guess caused because didn't include jar files in compile command.

there many jar files included in project , java newbie far haven't found way compile project works in eclipse shell.

does know if there way appropriate compile command directly eclipse , paste shell or have include jars 'manually'? if case, know how include jars, placed in lib directory located in same folder myproject.java?

thank you!

if learning java, suggestion may challenge, use maven build project, requires reorganizing source files , directories. , use assembly plugin create zip includes dependencies. run program, like:

unzip myapp.zip cd myapp java -cp "lib/*" com.blah.myapp 

(you might need adjust syntax of /* part, using single quotes, or removing quotes depending on shell)

here snippet assembly plugin (general purpose... nothing hardcoded other version, , path follows conventions). goes in pom.xml:

<plugin>     <artifactid>maven-assembly-plugin</artifactid>     <version>2.2</version>     <configuration>         <descriptors>             <descriptor>src/main/assembly/distribution.xml</descriptor>         </descriptors>         <appendassemblyid>false</appendassemblyid>     </configuration>     <executions>         <execution>             <id>make-assembly</id>             <!-- used inheritance merges -->             <phase>package</phase>             <!-- append packaging phase. -->             <goals>                 <goal>single</goal>                 <!-- goals == mojos -->             </goals>         </execution>     </executions> </plugin> 

and here example assembly file (this goes in src/main/assembly/distribution.xml relative pom.xml):

<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"     xmlns:xsi="http://www.w3.org/2001/xmlschema-instance"     xsi:schemalocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd" >     <id>${artifact.version}</id>     <formats>         <format>zip</format>     </formats>      <files>         <file>             <!-- example script instead of using "java -cp ..." each time -->             <source>${project.basedir}/src/main/bin/run.sh</source>             <outputdirectory>.</outputdirectory>             <destname>run.sh</destname>             <filemode>0754</filemode>         </file>     </files>      <filesets>         <fileset>             <directory>${project.basedir}/src/main/resources/</directory>             <outputdirectory>/res/</outputdirectory>             <includes>                 <!-- examples... -->                 <include>*.sql</include>                 <include>*.properties</include>             </includes>         </fileset>         <fileset>             <directory>config/</directory>             <outputdirectory>/config/</outputdirectory>         </fileset>     </filesets>      <dependencysets>         <dependencyset>             <outputdirectory>/lib</outputdirectory>             <excludes>                 <!-- add redundant/useless files here -->             </excludes>         </dependencyset>     </dependencysets> </assembly> 

also, eclipse has "jar packager" utility in gui, found not when used few years ago. , don't think handles dependencies, need take "-cp" argument above, , add jars, or put them in lib directory yourself.

also there http://fjep.sourceforge.net/ have never used it.... found while looking eclipse jar packager. in tutorial, last line (showing running it) looks like:

> java -jar demorun_fat.jar hello 

Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -