Link to home
Start Free TrialLog in
Avatar of ceasley
ceasley

asked on

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?
Avatar of petmagdy
petmagdy
Flag of Canada image

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

Avatar of ceasley
ceasley

ASKER

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 ! ! !
ASKER CERTIFIED SOLUTION
Avatar of kiranhk
kiranhk

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ceasley

ASKER

Thanks for the help guys . . .
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);
  }
}
Avatar of ceasley

ASKER

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....