Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8056649
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T08:46:40+00:00 2026-06-05T08:46:40+00:00

I have created a Java project in Eclipse and successfully executed it directly from

  • 0

I have created a Java project in Eclipse and successfully executed it directly from Eclipse on my Windows PC. Now I have to run the same java program on Linux server.

I have tried to copy the .class files from my PC to server and run it but it didn’t work. After that I copied the whole project and run javac MyProject.java from shell and it returned the following errors:

RecordImportBatch.java:2: error: package org.apache.commons.io does not exist
import org.apache.commons.io.FileUtils;

...

RecordImportBatch.java:3: error: package org.neo4j.graphdb does not exist
import org.neo4j.graphdb.RelationshipType;

which I guess are caused because I didn’t include jar files in compile command.

There are many jar files included in this project and as a Java newbie so far I haven’t found the way to compile the project which works in Eclipse from Shell.

Does anyone know if there is a way to get the appropriate compile command directly from Eclipse and just paste it to Shell or do I have to include all jars ‘manually’? If this is the case, does anyone know how to include all jars, placed in lib directory which is located in the same folder as MyProject.java?

Thank you!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T08:46:41+00:00Added an answer on June 5, 2026 at 8:46 am

    If you are just learning about java, this suggestion may be some challenge, but it would be good for you to use maven to build your project, which requires reorganizing your source files and directories. And then use the assembly plugin to create a zip that includes all dependencies. Then to run your program, you just do something like:

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

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

    Here is a snippet for the assembly plugin (general purpose… nothing hardcoded other than version, and the path which follows conventions). This 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>
                <!-- this is used for inheritance merges -->
                <phase>package</phase>
                <!-- append to the packaging phase. -->
                <goals>
                    <goal>single</goal>
                    <!-- goals == mojos -->
                </goals>
            </execution>
        </executions>
    </plugin>
    

    And here is an example assembly file (this goes in src/main/assembly/distribution.xml relative to 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>
                <!-- an 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>
                    <!-- just 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 a “jar packager” utility in the gui, but I found it to be not very good when I used it a few years ago. And I don’t think it handles dependencies, so you would need to take my “-cp” argument above, and add all the jars, or put them in your lib directory yourself.

    Also there is this http://fjep.sourceforge.net/ but I have never used it…. I just found it now while quickly looking up the eclipse jar packager. In his tutorial, his last line (showing running it) looks like:

    > java -jar demorun_fat.jar
    Hello
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have installed Maven 3.0.4 and now want to run already created java project
I have recently just created Java project using Eclipse that requires 2 JAR files
I have recently created a web project in Java using eclipse. I have a
I have created a java application for Debian Linux. Now I want that that
I have a java project. The working folder from someone else's Eclipse project (It
I have created simple Java Dynamic Web project in Eclipse. I host my project
I have created a local Groovy project in Eclipse. I am now starting to
I have created an applet program using Eclipse IDE. Now im creating .html file
I have created a google-app-engine java project in Eclipse using Google's Eclipse plugin. My
I have created a New --> Dynamic Web Project from Eclipse IDE , Modified

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.