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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T08:56:40+00:00 2026-05-29T08:56:40+00:00

My Question is: I have a test.java class which is the main class. There

  • 0

My Question is:

I have a test.java class which is the main class. There is one more class(non-main class) which is present in JAR file. Now i want to compile and execute demo class present in JAR from the main class present outside the JAR. Please explain why.

public class test
{   
public static void main(String args[])
{
    demo d1 = new demo();
    demo d2 = new demo("message passed from main class");
}
} 

public class demo
{
demo()}
System.out.println("message in demo class");
}
demo(String str)
{
System.out.println(str);
}}
  • 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-05-29T08:56:41+00:00Added an answer on May 29, 2026 at 8:56 am

    I guess the proper answer us ‘use ant’, but:

    javac test.java
    javac demo.java
    jar cf test.jar test.class demo.class
    jar ufe test.jar test
    

    and then,

    java -jar test.jar
    

    If you intend to expand on this, and continue not to use ant, you’ll likely want your build system to stop on an error, and will notice that ‘javac’ doesn’t return non-zero on error. Pipe its stderr to a temporary file and then quit depending on grep’s non-zero return of that file. e.g., from an on-device build script that cannot use ant:

    cd src
    for F in R.java Maze.java EmptyActivity.java; do
      javac -d ../build/classes $P/$F 2> ~/tmp/javac.out
      echo -en "\033[1m"; cat ~/tmp/javac.out; echo -en "\033[0m"
      grep error ~/tmp/javac.out && exit
    done
    cd ..
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple question related to one-line programming. First an example: function test(a)
I am fairly new to Java. I have constructed a single JUnit test class
My question is, In my code I have made a JTable in main class.
I have following problem to be solved in java: Implement class Alkio. Test with
I have a class say Test.java and it includes a member variable called errorCode
I have a simple unit test case (extensive question here ) on a configuration
I have a very simple question. I want to test whether a particular port
Following on from this question...I'm trying to unit test the following scenario: I have
Question I have an application written in Java. It is designed to run on
This maybe a related question: Java assignment issues - Is this atomic? I have

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.