Modules in java?

Is there a java equivalent to a module in VB. I am converting a VB application to java and the current VB app. uses a couple of modules. Is this functionality available in java?
ceasleyAsked:
Who is Participating?
 
kiranhkCommented:
No. if you dont specify any access specifiers for the variables in the class then all the classes within the same package will have access to it. if you specify like protected then only classes extending/inheriting it will get access, if it is public everyone will be having access which is not usually recommended, if private only that particular class can access it.
Even if you create a new package and import the package into your class, the same rules apply as told above while accessing the variables.

check out this
http://www.artima.com/objectsandjava/webuscript/PackagesAccess1.html
0
 
petmagdyCommented:
Java heirarchy is packages and classes

A class is an OOP class and a packages is a group of classes, also if ur platform is J2EE then their are Enterprise application that contains multiple modules, each module contains a group of packages + other things the module types mainly are:
1- Client Module correspondent to VB desktop application
2- Web Module that is web based application correspondent to asp.net and others
3- EJB module that is the business beans and the persisitance tier
4- other type of modules

0
 
ceasleyAuthor Commented:
So I can just create another class within the same package and my other classes will have access to the variables it holds? Or would it be better to create another package and import that package into the classes that need it. Thanks for the help ! ! !
0
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

 
ceasleyAuthor Commented:
Thanks for the help guys . . .
0
 
petmagdyCommented:
u can create ur whole application in one package, but if 2 classes are in different packages they can still access each other it is the matter of OOP, here is a simple example suppose Class1 is in package1 and Class2 in package2 wants to access it then here is the code

****************** Class1 code ***************************
package package1;

public class Class1
{
   protected String data;

   public Class1()
   {
   }

   public String getData()
   {
     return data;
   }
}




******************** Class2 code

package package2;

import package1.Class1;

public class Class2
{
 public void main(..)
 {
    Class1 cls1 = new Class1();
    String theData = cls1.getData();
    System,out.println(theData);
  }
}
0
 
ceasleyAuthor Commented:
My problem is the way the VB application is set up it accesses and changes the values withing the module. The module also has a couple of functions which it uses and passes the variable it holds to these functions. The variables are set by other classes outside the module. Basically the module is used as a set of global variables that all other functions use/modify. I need this same functionality in java or I am going to be rewriting a bunch of variables over and over. If I instantiate a variable in two different classes the main class will not have access to the same value I need it to have. I guess I am having a hard time saying what I need to, but it sounds like I can't accomplish what I want in java....
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.