6

Inside Eclipse Android project how to run Java classes with main(String[] args) as Java Application ?

public class JavaApp {
    public static void main(String[] args) {
        // some dummy operations here, possibly including 
        // System.out.print(string);
    }
}

I get error

Invalid layout of java.lang.String at value
#
# A fatal error has been detected by the Java Runtime Environment:
#
#  Internal Error (javaClasses.cpp:129), pid=6748, tid=6676
#  fatal error: Invalid layout of preloaded class
#
# JRE version: 7.0_11-b21
# Java VM: Java HotSpot(TM) 64-Bit Server VM (23.6-b04 mixed mode windows-amd64 compressed oops)
# Failed to write core dump. Minidumps are not enabled by default on client versions of Windows
#
# An error report file with more information is saved as:
# D:\Workspaces\ADT-Bundle\FMonPianoApp\hs_err_pid6748.log
#
# If you would like to submit a bug report, please visit:
#   http://bugreport.sun.com/bugreport/crash.jsp
#

I use main() for small tests (without JUnit)

2
  • I suggest you keep your Android code separate from your non-Android code... it's likely to make things much simpler. Commented Jan 21, 2014 at 8:15
  • Is the project defined as an Android project? Commented Jan 21, 2014 at 8:16

1 Answer 1

22

In case of an Android project, you have to remove Android Lib from the launch configuration for that specific class. Use the "walkthrough" below as a guide.

  • Project->Properties->Run/Debug Settings;
  • Select your Class and click "Edit";
  • Open the tab "Classpath" and remove Android Lib from "Bootstrap Entries";
  • Apply everything and Run the class again.

OR

You can get past this by using the Run As -> Android Application. Possibly check the Run configuration for other issues.

Hope this helps

Source

Sign up to request clarification or add additional context in comments.

3 Comments

@PaulVerest Mark the answer correct if it helped you. So that others can come to know which is the correct answer of the question.
Only after 10 min when SO allows
The best answer I have ever found the last day! Thank you!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.