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

  • Home
  • SEARCH
  • 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 6230863
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T09:49:46+00:00 2026-05-24T09:49:46+00:00

public class Strange1 { public static void main(String[] args) { try { Missing m

  • 0
public class Strange1 {
  public static void main(String[] args) {
    try {
      Missing m = new Missing();
    } catch (java.lang.NoClassDefFoundError ex) {
      System.out.println("Got it!");
    }
  }
}

public class Strange2 {
  public static void main(String[] args) {
    Missing m;
    try {
      m = new Missing();
    } catch (java.lang.NoClassDefFoundError ex) {
      System.out.println("Got it!");
    }
  }
}

class Missing {
  Missing() { }
}

If you run Strange1 and Strange2 after deleting Missing.class, Strange1 will throw NoClassDefFoundError; but Strange2 will print Got it!

Can anyone explain that? Thanks.

updated:

java bytecode for Strange1 :

     0  new info.liuxuan.test.Missing [16]
     3  dup
     4  invokespecial info.liuxuan.test.Missing() [18]
     7  astore_1 [m]
     8  goto 20
    11  astore_1 [ex]
    12  getstatic java.lang.System.out : java.io.PrintStream [19]
    15  ldc <String "Got it!"> [25]
    17  invokevirtual java.io.PrintStream.println(java.lang.String) : void [27]
    20  return
      Exception Table:
        [pc: 0, pc: 8] -> 11 when : java.lang.NoClassDefFoundError
      Line numbers:
        [pc: 0, line: 14]
        [pc: 11, line: 15]
        [pc: 12, line: 16]
        [pc: 20, line: 18]
      Local variable table:
        [pc: 0, pc: 21] local: args index: 0 type: java.lang.String[]
        [pc: 8, pc: 11] local: m index: 1 type: info.liuxuan.test.Missing
        [pc: 12, pc: 20] local: ex index: 1 type: java.lang.NoClassDefFoundError

java bytecode for Strange2 :

     0  new info.liuxuan.test.Missing [16]
     3  dup
     4  invokespecial info.liuxuan.test.Missing() [18]
     7  astore_1 [m]
     8  goto 20
    11  astore_2 [ex]
    12  getstatic java.lang.System.out : java.io.PrintStream [19]
    15  ldc <String "Got it!"> [25]
    17  invokevirtual java.io.PrintStream.println(java.lang.String) : void [27]
    20  return
      Exception Table:
        [pc: 0, pc: 8] -> 11 when : java.lang.NoClassDefFoundError
      Line numbers:
        [pc: 0, line: 15]
        [pc: 11, line: 16]
        [pc: 12, line: 17]
        [pc: 20, line: 19]
      Local variable table:
        [pc: 0, pc: 21] local: args index: 0 type: java.lang.String[]
        [pc: 8, pc: 11] local: m index: 1 type: info.liuxuan.test.Missing
        [pc: 12, pc: 20] local: ex index: 2 type: java.lang.NoClassDefFoundError

There is only one place is different:

11  astore_1 [ex]

and

11  astore_2 [ex]

updated again:

Everyone can try it in eclipse.

  • 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-24T09:49:48+00:00Added an answer on May 24, 2026 at 9:49 am

    Prior to saying anything, i doub’t this code won’t even compile. because when compiler cannot find a class (Since its deleted). may be you are getting an error when trying to compile it using javac command. if thats the case its pretty normal and in no way its weird.

    and let me add an another point.. check your imports, to contain Missing class. if it is there then remove it. and tell us whats happening.

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

Sidebar

Related Questions

public class Test { public static void main(String[] args) { } } class Outer
public class doublePrecision { public static void main(String[] args) { double total = 0;
public class WrapperTest { public static void main(String[] args) { Integer i = 100;
public class Main3 { public static void main(String[] args) { Integer min = Integer.MIN_VALUE;
public class Asterisk { public static void main(String[] args) { String output=""; int count=1,
public class CovariantTest { public A getObj() { return new A(); } public static
public class WrapperTest { static { print(10); } static void print(int x) { System.out.println(x);
I just saw code similar to this: public class Scratch { public static void
i am having a strange problem, i have a static class like this public
public class MyClass { public int Age; public int ID; } public void MyMethod()

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.