"Cannot find main" error when attempting to run "java name.class" file

I'm not a Java programmer, but my boss tasked me with getting someone else's code running. Sorry for the noob question.

I have the code running perfectly via `Eclipse` on my OSX system. However, the need is for it to be running from the command line.

I'm trying to run the code on my OSX box that was compiled by eclipse when I ran it there.

I've set up the environment as best I can. But when I attempt to run the *.class files, I get...

    init mikes$ pwd

    init mikes$ java Init.class
    Error: Could not find or load main class Init.class

    init mikes$ java ./Init.class
    Error: Could not find or load main class ..Init.class

`main` is definitely in Init.class


    package init;
    import java.io.File;
    import java.io.IOException;
    import java.nio.file.Files;
    import java.nio.file.Path;
    import java.nio.file.Paths;
    import java.util.stream.Stream;
    import java.net.*;
    import anonymizer.Anonymizer;
    public class Init  {
          public static String STOPWORDS;

          static {
                // Define location of resource files
                 STOPWORDS = "misc" + File.separator + "stopwordlist_de.txt";
          public static void main(String[] args) throws IOException {            
                if (args.length !=1) {
                      System.err.println("Usage: Anonymize <path to docx files>");
                try (Stream<Path> paths = Files.walk(Paths.get(args[0]))) {
                      paths.skip(1).filter(file -> file.toString().endsWith("docx")).forEach(file -> {
                                  Anonymizer ano;
                            try {
                                  // Creates an instance of the Anonymizer class and executes the pipeline
                                  ano = new Anonymizer(file.toString(), file.toString()+".anon");
                            } catch (Exception e) {
                    } catch (IOException e) {
                System.out.println("De-Identification finished.");

** Directory Structure **

    Anonymize mikes$ pwd
    Anonymize mikes$ find . | grep -v <non_pertinent_stuff>



** This is how I tried to setup the environment, and run the code. **

    init mikes$ export CLASSPATH="${CLASSPATH}:.:\

    init mikes$ export PATH="${PATH}:${CLASSPATH}"

    init mikes$ pwd

    init mikes$ java Init.class
    Error: Could not find or load main class Init.class

    init mikes$ java ./Init.class
    Error: Could not find or load main class ..Init.class

    init mikes$ java init.Init
    Error: Could not find or load main class java

**I'm not finding my mistake. What do I need to change/do, to get this code running from the command line?**

  [1]: https://stackoverflow.com/questions/18093928/what-does-could-not-find-or-load-main-class-mean
Mike R.Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

java -cp /Users/(snip)/Eclipseworkspace/Anonymize/bin init.Init

Open in new window

When they're done in the IDE, Java apps should be in executable jars (hint: 'export' in Eclipse)

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Mike R.Author Commented:
OK. That was it :) I tried a half doze variations of that I found on the web, but I was missing the `package` prefix. Thank you. I'll look for a link on how to export.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.