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.

  • Hitting resources in a private network from within a Docker container using VPN
  • dotnet core SDK/Runtime on debian in dockers
  • Populate cassandra after Docker-compose finishes
  • Mnesia doesn't recognize data after sys restart (no_exists error)
  • How to view the namespaces range of a Docker container to choose correct Samba domain member idmap range?
  • Why does using DOCKER_OPTS=“--iptables=false” break the DNS discovery for docker-compose?
  • 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.

  • Modify NODE_ENV accordingly
  • Running Docker and Jekyll together in a same ec2 instance
  • ssh: Could not resolve hostname (Docker, gitlab-ce)
  • Error response from daemon when starting a docker container
  • Docker Strategy
  • Docker within PCF - unable to connect to rabbitmq via AMQP (spring cloud bus)
  • 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.