Advertisement
Guest User

Untitled

a guest
Sep 20th, 2017
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.62 KB | None | 0 0
  1. Exception in thread "main" java.lang.NoClassDefFoundError: graphics/shapes/Square
  2. at Main.main(Main.java:7)
  3. Caused by: java.lang.ClassNotFoundException: graphics.shapes.Square
  4. at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
  5. at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
  6. at java.security.AccessController.doPrivileged(Native Method)
  7. at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
  8. at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
  9. at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
  10. at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
  11. ... 1 more
  12.  
  13. graphics
  14. ├ Main.java
  15. ├ shapes
  16. | ├ Square.java
  17. | ├ Triangle.java
  18. ├ linepoint
  19. | ├ Line.java
  20. | ├ Point.java
  21. ├ spaceobjects
  22. | ├ Cube.java
  23. | ├ RectPrism.java
  24.  
  25. import graphics.shapes.*;
  26. import graphics.linepoint.*
  27. import graphics.spaceobjects.*;
  28.  
  29. public class Main {
  30. public static void main(String args[]) {
  31. Square s = new Square(2,3,15);
  32. Line l = new Line(1,5,2,3);
  33. Cube c = new Cube(13,32,22);
  34. }
  35. }
  36.  
  37. On Compiling process use this command:
  38.  
  39. javac -d . [FileName.java]
  40.  
  41. To Run the class please use this command:
  42.  
  43. java [Package].[ClassName]
  44.  
  45. java.lang.NoClassDefFoundError
  46.  
  47. public class ClassA{
  48. public static void main(String args[]){
  49. //Some gibberish Code...
  50. String text = ClassB.getString();
  51. System.out.println("Text is :" + text);
  52. }
  53.  
  54. public class ClassB{
  55. public static String getString(){
  56. return "Testing Some Exception";
  57. }
  58. }
  59.  
  60. cd out
  61. java -classpath . com.blahcode.Main
  62.  
  63. // ClassLoaderTracer.java
  64. // From: https://blogs.oracle.com/sundararajan/entry/tracing_class_loading_1_5
  65.  
  66. import java.lang.instrument.*;
  67. import java.security.*;
  68.  
  69. // manifest.mf
  70. // Premain-Class: ClassLoadTracer
  71.  
  72. // jar -cvfm tracer.jar manifest.mf ClassLoaderTracer.class
  73.  
  74. // java -javaagent:tracer.jar [...]
  75.  
  76. public class ClassLoadTracer
  77. {
  78. public static void premain(String agentArgs, Instrumentation inst)
  79. {
  80. final java.io.PrintStream out = System.out;
  81. inst.addTransformer(new ClassFileTransformer() {
  82. public byte[] transform(ClassLoader loader, String className, Class classBeingRedefined, ProtectionDomain protectionDomain, byte[] classfileBuffer) throws IllegalClassFormatException {
  83.  
  84. String pd = (null == protectionDomain) ? "null" : protectionDomain.getCodeSource().toString();
  85. out.println(className + " loaded by " + loader + " at " + new java.util.Date() + " in " + pd);
  86.  
  87. // dump stack trace of the thread loading class
  88. Thread.dumpStack();
  89.  
  90. // we just want the original .class bytes to be loaded!
  91. // we are not instrumenting it...
  92. return null;
  93. }
  94. });
  95. }
  96. }
  97.  
  98. public class MyClass{
  99. private static Handler mHandler = new Handler();
  100. public static int num = 0;
  101.  
  102. @Override
  103. protected void onCreate(Bundle savedInstanceState) {
  104. super.onCreate(savedInstanceState);
  105. setContentView(R.layout.activity_main);
  106. //test code start
  107. new Thread(new Runnable() {
  108. @Override
  109. public void run() {
  110. try {
  111. MyClass myClass = new MyClass();
  112. } catch (Throwable e) {
  113. e.printStackTrace();
  114. }
  115. }
  116. }).start();
  117.  
  118. try {
  119. Thread.sleep(1000);
  120. } catch (InterruptedException e) {
  121. e.printStackTrace();
  122. }
  123. MyClass.num = 3;
  124. // end of test code
  125. }
  126.  
  127. private static Handler mHandler;
  128. private static HandlerThread handlerThread = new HandlerThread("newthread");
  129. static {
  130. handlerThread.start();
  131. mHandler = new Handler(handlerThread.getLooper(), mHandlerCB);
  132. }
  133.  
  134. compile 'com.google.android.gms:play-services-gcm:11.0.4'
  135. compile 'com.google.android.gms:play-services:11.0.4'
  136.  
  137. dependencies {
  138. compile fileTree(include: ['*.jar'], dir: 'libs')
  139. androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
  140. exclude group: 'com.android.support', module: 'support-annotations'
  141. })
  142. compile files('libs/ypylibs.jar')
  143. compile 'com.android.support:appcompat-v7:25.3.1'
  144. compile 'com.google.android.gms:play-services-gcm:11.0.4'
  145. compile 'com.google.android.gms:play-services:11.0.4'
  146. compile 'com.google.android.gms:play-services-ads:11.0.4'
  147. compile 'com.dailymotion.dailymotion-sdk-android:sdk:0.1.12'
  148. compile 'org.apache.httpcomponents:httpcore:4.4.1'
  149. compile 'commons-io:commons-io:1.3.2'
  150. compile 'com.oguzdev:CircularFloatingActionMenu:1.0.2'
  151. compile 'com.android.support:multidex:1.0.1'
  152. compile 'com.android.support.constraint:constraint-layout:1.0.2'
  153. testCompile 'junit:junit:4.12'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement