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

    Default setting class-path & Library Path in ubantu

    how to set classpath of a jar and librarypath of .so file in Ubantu ?

    i have a "abc.jar" file that i have to put into CLASSPATH.
    AND a native library "xyz.so" that i have to put into library path ..

    I was setting paths in project builds in Eclipse , but nothing worked out .
    now i want to run program out of eclipse.so how to set all these paths..

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

    Default

    When i execute Hi.java following happens. i am unable to use the "com.asprise.util.ocr"

    Java Code:
    sandeep@training-pc1:~$ javac Hi.java
    Hi.java:7: package com.asprise.util.ocr does not exist
    import com.asprise.util.ocr.OCR;
                               ^
    Hi.java:25: cannot find symbol
    symbol  : class OCR
    location: class Hi
    		  String s = new OCR().recognizeCharacters(image);

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

    Default

    Anybody ?

    nobody !!

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

    Default

    You set the classpath using the -cp flag for both the javac and java commands.
    You set the library path using the -Djava.library.path flag to the java command.

    Also read this thread:
    want to add Asprise jar file as well as its lib file

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

    Default

    Java Code:
     javac -classpath /home/sandeep/Downloads/Asprise/aspriseOCR.jar Hi.java
    above worked for class path .. and creates the .class file , but when i run it , this happens
    Java Code:
    Exception in thread "main" java.lang.NoClassDefFoundError: com/asprise/util/ocr/OCR
    	at Hi.main(Hi.java:25)
    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
    something wrong with library path ,, i guess.
    Also read this thread:
    want to add Asprise jar file as well as its lib file
    this thread is confusing

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

    Default

    There is nothing wrong with the library path.
    Did you get the correct asprise.jar or are you still trying to use the one that you (incorrectly) created?

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

    Default

    no m not using the one i made yesterday .. i have got aspriseOCR.jar already packaged , that i have downloaded .... when i tried these stuffs on windows .. it worked
    but something wrong when m doing in linux ubantu

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

    Default

    Did you add the cp flag to the java command too like I said above?
    Post your full run command.

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

    Default

    Java Code:
    sandeep@training-pc1:~$ javac -cp /home/sandeep/Downloads/Asprise/aspriseOCR.jar Hi.java
    sandeep@training-pc1:~$ 
    sandeep@training-pc1:~$ 
    sandeep@training-pc1:~$ java -cp /home/sandeep/Downloads/Asprise/aspriseOCR.jar Hi.java
    Exception in thread "main" java.lang.NoClassDefFoundError: Hi/java
    Caused by: java.lang.ClassNotFoundException: Hi.java
    	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)
    Could not find the main class: Hi.java.  Program will exit.
    sandeep@training-pc1:~$

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

    Default

    can i extract the jar to get the class files and then put those class files in the local directory of my program, ie all the classes in the same directory, and then run it .. wht say ?

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

    Default

    You don't run .java files, you run .class files.
    When running the .class files you simply give the name of the class without the .class extension. These are basics that you should have read about before you wrote your first java program.

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

    Default

    yaah man ... i know these ...
    Java Code:
    sandeep@training-pc1:~$ java -cp /home/sandeep/Downloads/Asprise/aspriseOCR.jar Hi
    Exception in thread "main" java.lang.NoClassDefFoundError: Hi
    Caused by: java.lang.ClassNotFoundException: Hi
    	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)
    Could not find the main class: Hi.  Program will exit.
    sandeep@training-pc1:~$ ^C
    sandeep@training-pc1:~$

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

    Default

    the instruction in READ ME file are :

    ♦ Put aspriseOCR.jar into your class path, and

    and for libAspriseOCR.so file , <native library>
    ♦ Put the native library into the library path.

    wht will the scholar do ?

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

    Default

    No you don't know these. That is why you are having problems.
    You also can't read the responses I'm posting.

    1.) You also need to have the folder containing the Hi.class file on the classpath as well.
    2.) You still didn't specify the library path.

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

    Default

    appreciate your time for the thread .. but problem is also unidentified by you ... it is somethng else. . coz i think i have tried all the flags and combinations.. but its still unsolved.

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

    Default

    1.) You also need to have the folder containing the Hi.class file on the classpath as well.
    2.) You still didn't specify the library path.
    the folder containing Hi.class is the very folder that contains aspriseOCR.jar , so its already in the classpath,,

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

    Default

    No it's not. You need to add it (.) the current directory but I guess I'm wasting my time here because you think that I'm wrong even though I'm trying to give you free help.
    Thank you for (indirectly) asking me not to reply to you.

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

    Default

    Thank you for (indirectly) asking me not to reply to you
    ]
    come on .. dude !!! its not like that ....i appreciate ur time and help !! but u know i m stuck from more than 2 day on these stuff . understand.... i dint meant that ..

    its only becoz m done with today's work .... now no more till 2morro

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

Similar Threads

  1. Setting path under Linux to recognize jre
    By cccccc in forum New To Java
    Replies: 4
    Last Post: 03-31-2009, 06:51 AM
  2. URGENT: How to include a library in Java class path?
    By gsmurthy30 in forum New To Java
    Replies: 3
    Last Post: 09-15-2008, 04:58 PM
  3. URGENT: How to include a library in Java class path?
    By gsmurthy30 in forum Advanced Java
    Replies: 1
    Last Post: 09-15-2008, 08:39 AM
  4. Setting up class path for Eclipse
    By tsantana in forum Eclipse
    Replies: 1
    Last Post: 04-07-2008, 07:05 PM
  5. Setting Java Path
    By bugger in forum New To Java
    Replies: 2
    Last Post: 11-22-2007, 09:48 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
  •