Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

jagatuba

  • 4 years ago

Okay since .class files use the JRE to run, this theoretically makes them platform-independent. Since, the class file contains the byte-code to that the JRE uses to run it, it should run whether that JRE resides on a Windows machine, a Linux box, or on a Mac. I wrote a Java program and the class file executes perfectly on my Windows laptop, but will not work on my Mac. When I try to run it in OS X I get the following error:

  • This Question is Closed
  1. jagatuba
    • 4 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    Exception in thread "main" java.lang.NoClassDefFoundError: CalMortCalc$Interact at CalMortCalc.<init>(CalMortCalc.java:384) at CalMortCalc.main(CalMortCalc.java:522) Caused by: java.lang.ClassNotFoundException: CalMortCalc$Interact at java.net.URLClassLoader$1.run(URLClassLoader.java:202) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:190) at java.lang.ClassLoader.loadClass(ClassLoader.java:307) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301) at java.lang.ClassLoader.loadClass(ClassLoader.java:248) ... 2 more

  2. jayanth.log
    • 4 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    no dude the .class file is common to all the platforms there might be any warning in your code please note it.

  3. rsmith6559
    • 4 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    Where is CalMortCalc$Interact.class located when you run it on OSX? Do you need to adjust/declare a CLASSPATH variable?

  4. jagatuba
    • 4 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    I figured it out. I had forgotten that I had created and implemented a class called interact within the program. At compile time java automatically creates that class file (CalMortCalc$Interact). Both of those files must be present for the program to execute, but I only copied the CalMortCalc.class, not both. I brought over CalMortCalc$Interact.class and the program works fine. Sometimes it is the simplest things that leave you puzzled. Turns out all I really needed was a little sleep. lol

  5. Not the answer you are looking for?
    Search for more explanations.

    • Attachments:

Ask your own question

Sign Up
Find more explanations on OpenStudy
Privacy Policy