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 828497
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T03:43:59+00:00 2026-05-15T03:43:59+00:00

I am new to Java and am making a license generator. This is my

  • 0

I am new to Java and am making a license generator. This is my current setup.

com.example.licensegenerator.client (used by the client application)
   :LicenseLoader (no Main method)
   :LicenseDownloader (no Main method)

com.example.licensegenerator.server.keys (used by the server)
   :ProductKeyGenerator(Main method)

com.example.licensegenerator.server.license (used on the server also)
   :LicenseGenerator(Main method)

com.example.licensegenerator.lib (Shared classes between client and server)
    :Contants (no main)

Now I have a few questions.

  1. Is it OK to have multiple main() methods in a single project? Will I be able to compile them to different .jar files? (In this case I need two different jars for the server)

  2. Is there a better way to setup the packages?

  3. And a totally unrelated question, with exceptions, is it better to handle them right then and there or throw them and let the main method catch them all (the program cannot recover if an error occurs)

  • 1 1 Answer
  • 1 View
  • 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-05-15T03:44:00+00:00Added an answer on May 15, 2026 at 3:44 am
    1. It is okay if you have multiple classes with main methods. Only you need to do is to specify the class which executes first while executing.

      java [Starting class full qualified name]
      

      Also, you can package the classes into multiple jar files. See the jar command structure at

      http://java.sun.com/j2se/1.4.2/docs/tooldocs/windows/jar.html

      In this, you can specify the classes you want to package into jar.

    2. It seems your package structure is okay no need to change it.

    3. Exception handling depends on the context. For example if it is known exception and if you want to give message to the user, better handle it in the class itself but if it is unknown exception, then throw it and handle it in main where you may want to print stack trace.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

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.