File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes How do I compile and run programs in packages? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "How do I compile and run programs in packages?" Watch "How do I compile and run programs in packages?" New topic

How do I compile and run programs in packages?

Esther Kak
Ranch Hand

Joined: Oct 11, 2006
Posts: 51
I have two programs in the same package but I am not sure how to run the program. I was able to compile using help from Javaranch member. Now how do I execute the same. I compiled using this command.
javac and it worked.
Also, my question is what do I have to keep in mind while running programs in packages. Please help.
Program1 - - has a variable and a method which are public. But the class is default.

Program2 - - should be able to access the public members of the class in the same package. I have the main method defined in this program.
Mark Uppeteer
Ranch Hand

Joined: Mar 02, 2004
Posts: 159

java compile tutorial


I know where my towel is. (SCJP 5, OCPJWCD)
[Free Quiz Tips for a fun night with friends or family] Flash games
Alejandro Galv�n

Joined: Nov 17, 2007
Posts: 17

Like Mark said you, you can look for how to configure the path variables and the compile tutorial.

More information for you: if you have your classes in a package: "Ekak.MyFavorites.Certification.KhalidMughal.PackageA", you can only run the one which have the main() method, in adittion, that if you already have the path variables configurated, you must call the class like: "java Ekak.MyFavorites.Certification.KhalidMughal.PackageA.AnyClassA".

I mean you must write all the path of (means direccion) of the class.

I agree. Here's the link:
subject: How do I compile and run programs in packages?
It's not a secret anymore!