• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How do I compile and run programs in packages?

 
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 AnyClassA.java SuperClassA.java and it worked.

Also, my question is what do I have to keep in mind while running programs in packages. Please help.
Program1 - SuperClassA.java - has a variable and a method which are public. But the class is default.

Program2 - SubClassA.java - should be able to access the public members of the class in the same package. I have the main method defined in this program.
 
Ranch Hand
Posts: 159
Eclipse IDE C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
java compile tutorial

classpath
 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi:

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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic