Page 1 of 2 12 LastLast
Results 1 to 20 of 21

Thread: PHP Java

  1. #1
    wenkep3 is offline Member
    Join Date
    Jun 2011
    Posts
    10
    Rep Power
    0

    Default PHP Java

    I wrote a program to resize images. PHP passes the file's directory and name as well as what to name the new file. The problem occurs when I run the java program from terminal, but it smoothly in eclipse. I'm using imgscalr for the image processing which is a jar file. In terminal I'm running "java -classpath /home/paul/path/to/java/program/ uploadImage image0.jpg renderedImage0.jpg". (without quotes). The error I'm receiving is:

    java.lang.ClassNotFoundException: com.thebuzzmedia.imgscalr.Scalr
    at java.net.URLClassLoader$1.run(URLClassLoader.java: 217)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.j ava:205)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:3 21)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launche r.java:294)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:2 66)
    ... 2 more

    Anyone know the reason behind this?

    Thanks

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,318
    Rep Power
    25

    Default

    .ClassNotFoundException: com.thebuzzmedia.imgscalr.Scalr
    Where is the missing class? The java program can not find it.
    You need to find the jar file it is in an put it on the classpath. The filename must be on the classpath, not just the folder the jar file is in.

  3. #3
    wenkep3 is offline Member
    Join Date
    Jun 2011
    Posts
    10
    Rep Power
    0

    Default Jar file

    I copied the jar file into same directory as the java file. So would something like this be the fix?
    system("java -classpath $javaClassPath;$javaClassPath/$javaJarFile uploadImage $tmpFile $fileName");

  4. #4
    wenkep3 is offline Member
    Join Date
    Jun 2011
    Posts
    10
    Rep Power
    0

    Default New error

    It appears what I just previously posted fixed that problem. I'm now receiving a new problem which says
    Failed to load Main-Class manifest attribute from
    /home/paul/public_html/website/java/bin/imgscalr-lib-3.1.jar

  5. #5
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,318
    Rep Power
    25

    Default

    That error sounds like you were using the java command -jar option. It tries to read a Main-Class: attribute from the manifest file in the jar file.

  6. #6
    wenkep3 is offline Member
    Join Date
    Jun 2011
    Posts
    10
    Rep Power
    0

    Default

    I dont follow: heres the whole command I'm trying to execute:
    java -classpath home/paul/public_html/java/bin/;"home/paul/public_html/java/bin/imgscalr.jar uploadImage $tmpFile $newFileName

  7. #7
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,196
    Rep Power
    19

    Default

    java -classpath home/paul/public_html/java/bin/;"home/paul/public_html/java/bin/imgscalr.jar uploadImage $tmpFile $newFileName
    What's that double quote for?

    db

  8. #8
    wenkep3 is offline Member
    Join Date
    Jun 2011
    Posts
    10
    Rep Power
    0

    Default

    just a typo. Its not in the source file

  9. #9
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,318
    Rep Power
    25

    Default

    Your postings have different jar names in them:
    /home/paul/public_html/website/java/bin/imgscalr-lib-3.1.jar
    vs
    home/paul/public_html/java/bin/imgscalr.jar

    Are those typos also?
    Its best to copy and paste the console output and file contents vs trying to type it in.
    It's impossible to debug something that is a typo.

  10. #10
    wenkep3 is offline Member
    Join Date
    Jun 2011
    Posts
    10
    Rep Power
    0

    Default

    I moved the jar file from its original location, which worked in eclipse but not in terminal, to a place where terminal can now see it. But now I'm getting this: Failed to load Main-Class manifest attribute from.
    So just to be clear I'm using this command:
    java -classpath home/paul/public_html/java/bin/;home/paul/public_html/java/bin/imgscalr.jar uploadImage $tmpFile $newFileName

  11. #11
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,318
    Rep Power
    25

    Default

    What version of java is the java command you are executing? Is it from Oracle?
    Also is there anything in the code you are executing that would try to read a manifest attribute? That includes what is in the jar file.

  12. #12
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,318
    Rep Power
    25

    Default

    What version of java is the java command you are executing? Is it from Oracle?
    Also is there anything in the code you are executing that would try to read a manifest attribute? That includes what is in the jar file.

  13. #13
    wenkep3 is offline Member
    Join Date
    Jun 2011
    Posts
    10
    Rep Power
    0

    Default

    Java Version 1.6.0_20 from Sun Microsystems Inc.
    I'm unfamiliar with manifest attribute so I couldn't answer that question. Here's a link to imgscalr's jar file if you want to download it and take a look.
    imgscalr

  14. #14
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,318
    Rep Power
    25

    Default

    Does the API doc for the classes you are using say anything about a Main-Class manifest attribute?

  15. #15
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,318
    Rep Power
    25

    Default

    Here is the console I get when I try to execute a jar file without a manifest:
    C:\Documents and Settings\Owner\My Documents\Downloads\imgscalr-lib-3.1>D:\Java\jre1.6.0_02\bin\java.exe -Xmx128M -jar "C:\Documents and Settings\Owner\My Documents\Downloads\imgsc
    alr-lib-3.1\imgscalr-lib-3.1-sources.jar"
    Failed to load Main-Class manifest attribute from
    C:\Documents and Settings\Owner\My Documents\Downloads\imgscalr-lib-3.1\imgscalr-lib-3.1-sources.jar

    C:\Documents and Settings\Owner\My Documents\Downloads\imgscalr-lib-3.1>MORE
    Somehow you are using the -jar option for java to look in the jar file that doesn't have the manifest.

  16. #16
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,318
    Rep Power
    25

    Default

    Is the command you are using: java
    a script or batch file and NOT the java program from Oracle?

  17. #17
    wenkep3 is offline Member
    Join Date
    Jun 2011
    Posts
    10
    Rep Power
    0

    Default

    The API doesn't say anything about the Main-Class manifest attribute. The command is a script.

  18. #18
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,318
    Rep Power
    25

    Default

    The command is a script.
    What does the script do?

  19. #19
    wenkep3 is offline Member
    Join Date
    Jun 2011
    Posts
    10
    Rep Power
    0

    Default

    I've been looking around eclipse and I found the command it executes for the program:
    java -classpath /home/paul/public_html/java/bin:/home/paul/public_html/java/bin/imgscalr-lib-3.1.jar uploadImage

    I put that in terminal and I'm no longer receiving any class or manifest errors. I believe I should be able to finish the project from here.
    Thanks for the help.

  20. #20
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,318
    Rep Power
    25

    Default

    AHHHH. the path separator char is : vs ;
    -classpath home/paul/public_html/java/bin/;home/paul/public_html/java/bin/imgscalr.jar
    vs
    -classpath /home/paul/public_html/java/bin:/home/paul/public_html/java/bin/imgscalr-lib-3.1.jar


    The script must have tried to execute the jar file following the ;

Page 1 of 2 12 LastLast

Posting Permissions

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