Results 1 to 11 of 11
  1. #1
    programmer_007's Avatar
    programmer_007 is offline Senior Member
    Join Date
    Aug 2009
    Posts
    125
    Rep Power
    0

    Default how to a class if dont have its .java file.

    In eclipse

    .java files reside in "src" folder and .class file reside in "bin" folder.

    i have a class name "a.class" in bin folder, of which i dont have source file or .java file.. now i want to use this a.class in another java program.
    is it necessary to have source file also . coz whenever i use this a.class file in other program i get error.. how to use it without its .java file

  2. #2
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    8

    Default

    You will need to add the class to your classpath.
    Best is to package the class into a jar file and add that jar file to your project's build path.

  3. #3
    programmer_007's Avatar
    programmer_007 is offline Senior Member
    Join Date
    Aug 2009
    Posts
    125
    Rep Power
    0

    Default

    You will need to add the class to your classpath.
    Best is to package the class into a jar file and add that jar file to your project's build path.
    can you please explore in steps , how to do this .

  4. #4
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    8

    Default

    Google "how to create a jar file" and read the first link that comes up.

  5. #5
    programmer_007's Avatar
    programmer_007 is offline Senior Member
    Join Date
    Aug 2009
    Posts
    125
    Rep Power
    0

    Default

    i made jar ... added external jar to build path.. and now the erroe is
    Java Code:
    Exception in thread "main" java.lang.NoClassDefFoundError: com/asprise/util/ocr/OCR
    	at Hi.main(Hi.java:21)
    Caused by: java.lang.ClassNotFoundException: com.asprise.util.ocr.OCR
    	at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
    	at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
    	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    	at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
    	at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
    	... 1 more

  6. #6
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    8

    Default

    You need the asprise.jar file to be on your classpath when running the application.

  7. #7
    programmer_007's Avatar
    programmer_007 is offline Senior Member
    Join Date
    Aug 2009
    Posts
    125
    Rep Power
    0

    Default

    You need the asprise.jar file to be on your classpath when running the application.
    And how can we do this ?

  8. #8
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    8

    Default

    The same way you added the external jar to the build path.

  9. #9
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    8

    Default

    The same way you added the external jar to the build path.

  10. #10
    programmer_007's Avatar
    programmer_007 is offline Senior Member
    Join Date
    Aug 2009
    Posts
    125
    Rep Power
    0

    Default

    asprise.jar ?

    the jar i made is OCR.jar. i dont have any jar called asprise.jar

  11. #11
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    8

    Default

    You are attempting to use com/asprise/util/ocr/OCR which is in asprise.jar. So get the asprise.jar rather than incorrectly trying to make your own.

Similar Threads

  1. need help.. java class file...
    By Madz in forum New To Java
    Replies: 3
    Last Post: 11-21-2009, 03:42 AM
  2. Replies: 10
    Last Post: 11-01-2009, 09:42 PM
  3. converting java class file to exe file
    By satheeshtech in forum Advanced Java
    Replies: 5
    Last Post: 07-18-2009, 11:47 PM
  4. .class file to .java file
    By makpandian in forum New To Java
    Replies: 1
    Last Post: 02-20-2009, 06:46 PM
  5. dont let me create simple class
    By itaipee in forum New To Java
    Replies: 5
    Last Post: 01-11-2009, 11:07 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •