Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Modules in java?

Posted on 2004-10-22
6
Medium Priority
?
512 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Suggested Courses

636 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