Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

Running java from command line; does package statement matter?

I usually run my Java programs using the jar file with:

C:\>java -jar progname.jav

but

I want to run it by just using while I'm in the right directory with:

C:/>java programname

where programname.class is in this same directory

It's a multi class program with a package statement. My text doesn't help much.

Can anyone help me?

Thanks

Update:

I just experimented and ran another program that did not have a package statement and it ran fine. However, this other program is also a single class

Update 2:

I did some experimenting and found out that I need to put all the class files into a folder with the same name as the class and then (from the directory where the folder is, not withing the folder), type:

C:/>java pakname.progname

where pakname is both the name of the package and the folder.

1 Answer

Relevance
  • 1 decade ago
    Favorite Answer

    yes,!

    you description about package is correct.

    Mentioning the package name is not mandatory unless ur command line is outside the pakage folder.

    Try to paste the exact error wat u got

Still have questions? Get your answers by asking now.