Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8717135
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T06:14:31+00:00 2026-06-13T06:14:31+00:00

I have two packages inside my project, a and b . a is my

  • 0

I have two packages inside my project, a and b.

a is my “main class” that runs when the program runs but I need to make b run from a (if that makes sense).

I’m sure its something along the lines of PackageB.BMain but I’m not sure.

Edit:

Okay so I’ve learned a few new things, to start my main project is RevIRC, inside that I have two packages, MainChat and RevIRC, now when I run the program RevIRC is ran, I need to make Mainchat run when RevIRC is ran.

Like I said before I’m sure its something along the lines of RevIRC.MainChat.ChatMain() but I can’t seem to figure it out.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T06:14:32+00:00Added an answer on June 13, 2026 at 6:14 am

    You have 2 options:

    • Either create a new instance of B from A, like so: PackageB.BMain b = new PackageB.BMain();
    • Access the methods in BMain in a static way like so: PackageB.BMain.someMethod();`

    Note that you can use either of these exclusively or mix them up together, however, it all depends on how you have written your BMain class.

    So for instance:

    package PackageB
    
    public class BMain
    {
        public BMain()
        { }
    
        public void foo()
        {
            System.out.println("This is not a static method. It requires a new instance of BMain to be created for it to be called");
        }
    
        public static void bar()
        {
            System.out.println("This is a static method. It can be accessed directly without the need of creating an instance of BMain");
        }
    }
    

    Then in your main class (the class which has the main method):

    package PackageA
    
    public class AMain
    {
    
        public static void main(String[] args)
        {
            PackageB.BMain.bar();
    
            PackageB.BMain bInstance = new PackageB.BMain();
            bInstance.foo();
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two nested packages that I am calling via fast_cgi. From the first
I'm learning about packages. I have two classes that are in different packages and
I have two different packages inside of my application. The trouble I am having
Suppose I just created a package example and have two classes inside it, Main
A very strange thing indeed. I have the following project structure: myproject/one/two Inside package
I have two different project A & B. Inside the project A I link
I have a products.jar file. Inside that there is one class com.ClassA . The
I have two packages - x and y. x contains the Student class and
I have two packages in my app com.first.main and com.second.activity2. I have tried this
I have two enums, in two packages. I could have 1000 enums, un 1000

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.