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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T01:03:36+00:00 2026-05-23T01:03:36+00:00

The problem: I can’t get my java app to run after compiling. My guess

  • 0

The problem:

I can’t get my java app to run after compiling. My guess is there’s something wrong my classpaths.

Just to clear things up I have used an IDE, Eclipse, and I originally used that to compile and run my application. It ran perfectly, but now I need to run it strictly through the terminal/command line. The reason is that I follow a guideline that if it cant be run on the command line then it doesn’t exist. (Helps me really get to know my applications)

Anyway here’s the environment

OS

32bit Linux AWS distro (Based off of CentOS)

Installed software

  • yum install subversion*
  • yum install java*

The Application structure

  • staff/src/com/staffS3/Helpers/Constants.java
  • staff/src/net/UploadFile.java

Classpaths

  • export CLASSPATH=”/home/ec2-user/staff/lib/aws-java-sdk-1.2.1.jar:.”
  • export JAVA_HOME=”/usr/lib/jvm/jre/”

Compiling

javac /home/ec2-user/staff/src/com/staffS3/Helpers/Constants.java /home/ec2-user/staff/src/net/UploadFile.java

Compiles correctly (Atleast without any errors)

To run it

java UploadFile

Error

    Exception in thread "main" java.lang.NoClassDefFoundError: UploadFile (wrong name: net/UploadFile)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:634)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:277)
at java.net.URLClassLoader.access$000(URLClassLoader.java:73)
at java.net.URLClassLoader$1.run(URLClassLoader.java:212)
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: UploadFile. Program will exit.

Been at this for a while. Hopefully someone will notice that little(or huge) thing I’m missing :).

Thanks in advance

  • 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-23T01:03:37+00:00Added an answer on May 23, 2026 at 1:03 am

    To run it

    java UploadFile
    

    You musn’t cd into the src/net directory. Just go to src and do

    java net.UploadFile
    

    You need to stand in a directory such that java can find the file net/UploadFile.class.

    The “Wrong Name” error message (and it’s cause) is described well here.


    Note also that setting the classpath through -cp is the preferred way. I.e., try

    java -cp .:/home/ec2-user/staff/lib/aws-java-sdk-1.2.1.jar net.UploadFile
    

    Finally, mixing .java files and .class files is a bad idea. Use the -d switch when running javac to specify a destination directory for the class files. Call the directory bin or build.

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

Sidebar

Related Questions

I've created a custom exception for a very specific problem that can go wrong.
My problem is that I can't seem to get the image from my bundle
I have problem compilin this code..can anyone tell whats wrong with the syntax CREATE
I am just facing a problem,can not able to overcome(make be lack of proper
I solved the N- Queen problem with the condition that there can only be
Problem: How can I tell if a selection of text in the CRichEditCtrl has
I have a script that constantly segfaults - the problem that I can't solve
I can't quite figure out this syntax problem with a case expression in a
Hopefully I can do the problem justice, because it was too difficult to summarise
I can't seem to find an answer to this problem, and I'm wondering if

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.