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 6201931
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T04:38:31+00:00 2026-05-24T04:38:31+00:00

Luckily or unluckily, I haven’t had to work too extensively with invoking java from

  • 0

Luckily or unluckily, I haven’t had to work too extensively with invoking java from the commandline up until this point, I’ve usually been using something like Maven, Ant, or running things within a servlet container. I’ve just compiled my application in Maven into one JAR using the assembly:single goal, and am having serious problems running it from the commandline.

Here’s what I’m attempting to do:

export JAVA_CLASSPATH="`pwd`:/path/to/remote/libs/"
java -cp "${JAVA_CLASSPATH}" -jar groupId-artifactId-version-jar-with-dependencies.jar com.my.main.Class

This is failing with the following error:

Exception in thread "main" java.lang.NoClassDefFoundError: com/remote/lib/IServer
Caused by: java.lang.ClassNotFoundException: com.remote.lib.IServer
    at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
Could not find the main class: com.my.main.Class. Program will exit.

The IServer class is in the /path/to/remote/libs directory and isn’t being found. It also seems to not be able to find the main class, which is really odd. What am I doing wrong?

  • 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-05-24T04:38:32+00:00Added an answer on May 24, 2026 at 4:38 am

    @Kal’s answer is correct, but an easier way to fix it would be this:

    export JAVA_CLASSPATH="groupId-artifactId-version-jar-with-depencies.jar:`pwd`:/path/to/remote/libs/iserver.jar"
    java -cp "${JAVA_CLASSPATH}" com.my.main.Class
    

    No need to tinker with the manifest file; just add the jar you want to the classpath.

    Also, if the IServer stuff is in a jar inside /path/to/remove/libs/ then you need to explicitly include the name of the jar file. I’ve included it above and assumed it is called “iserver.jar”

    If you have many dependencies then it’s often easier to write a shell script for launching your code. The script can build a (potentially very large) classpath string using shell glob goodness. The java executable doesn’t do any globbing.

    EDIT: Note that I’ve assumed that you don’t have access to Ant or Maven or any of that good stuff, since you stated that you usually use those tools but are not doing it right now.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Update Luckily, the code that WebKit uses to make this control draws onto a
I'm trying to create a .resx file from a dictionary of strings. Luckily the
Yesterday I had problems with another boost functions but luckily you guys helped me
This is a weird problem, which luckily (?) also happens on other machines. I've
My colleague tried to do a git pull from our master. He got this
One of our staff members has lost his mailbox but luckily has a dump
I'm trying to load Gravatars into Flash. Luckily, they provided a crossdomain.xml file at
I have a problem with a deadline. And that deadline is tomorrow :S Luckily
two questions today, I'm a busy bee and luckily I have an awesome community
We recently went into private beta on our flagship product and had a small

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.