[Webinar] Streamline your web hosting managementRegister Today

x
?
Solved

Modules in java?

Posted on 2004-10-22
6
Medium Priority
?
517 Views
Last Modified: 2013-11-23
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?
0
Comment
Question by:ceasley
  • 3
  • 2
6 Comments
 
LVL 13

Expert Comment

by:petmagdy
ID: 12384576
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
 

Author Comment

by:ceasley
ID: 12384713
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
 
LVL 8

Accepted Solution

by:
kiranhk earned 150 total points
ID: 12384756
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
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 

Author Comment

by:ceasley
ID: 12384796
Thanks for the help guys . . .
0
 
LVL 13

Expert Comment

by:petmagdy
ID: 12384813
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
 

Author Comment

by:ceasley
ID: 12399278
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

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
Suggested Courses

612 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question