How to build Dockerfile with two jar files

I’m starting with Docker and I’m a little bit lost.

I have my java experiment with two jar files, zip files with testing data and two configuration files.
And I’m trying to run this exp on Docker.

  • If images in Docker are untagged, are they used at all or just orphans?
  • Django can't connect to Postgres in Docker setup
  • Docker container can reach DNS but not resolve hosts
  • Maintaining infra Oracle WebLogic/SOA/BPM on top of Docker
  • Heredoc on docker exec
  • how to run a daemon process in docker container with API/v1.5?
  • If I want to run this exp on my pc there are two phases.

    Phase 1:

    java -classpath library.jar;alg.jar library.utl.App.class in.cf
    

    where the last parameter is configuration and after this I’ll get generated file alg1.bin

    Phase 2:

    java -classpath library.jar;alg.jar library.utl.App.class ot.cf
    

    where I’m working with file alg1.bin and this is main test.

    I used Dockerfile for phase 1:

    FROM java:7
    
    ADD java-exp /usr/local/
    
    CMD ["java", "-classpath",
    "/usr/local/library.jar;/usr/local/alg.jar",
    "/usr/local/library.utl.App.class", "/usr/local/in.cf"]
    

    This I built successfully but when I try

    docker run java-exp
    

    I get an error:

    Error: Could not find or load main class
    .usr.local.library.utl.App.class.

    Can anyone help me to solve this?

    In the better way, help me merge both two phases into one Dockerfile?
    Thanks.

  • Docker mono dns issue
  • Sidekiq using the incorrect url for redis
  • Docker volume binding: Base image vs derivative image
  • Docker image of Java project
  • how to change cassandra docker config
  • allow insecure registry in host provisioned with docker-machine
  • 2 Solutions collect form web for “How to build Dockerfile with two jar files”

    Try

    FROM java:7
    
    ADD java-exp /usr/local/
    
    WORKDIR /usr/local/
    
    CMD ["java", "-classpath","library.jar;alg.jar","library.utl.App.class","in.cf"]
    

    I think I solved it.
    Main mistake was in CMD

    The right thing is:

    CMD ["java", "-classpath",
    "/usr/local/library.jar:/usr/local/alg.jar",
    "/usr/local/library.utl.App", "/usr/local/in.cf"]
    

    Instead of:

    CMD ["java", "-classpath",
    "/usr/local/library.jar;/usr/local/alg.jar",
    "/usr/local/library.utl.App.class", "/usr/local/in.cf"]
    

    Two little mistakes :,; and .class

    Thanks for help.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.