1

I ' m programming with JSE and i'm loading a jar (that i do ) with another java program . The problem is in classLoader of java virtual machine i think . i said that beacuse i tried to exec the file jar with java -jar "file.jar" and it runs . I'm using xubuntu with eclipse. In eclipse, i have 2 project that respectively are the first software that loads jar and the jar software . To export the jar file i use the wizard "Export -> jar ecc...." How can i resolve this problem?

Exception in thread "main" java.lang.UnsatisfiedLinkError: /media/sda4/so_project/proj/example/first.jar: /media/sda4/so_project/proj/example/first.jar: invalid ELF header (Possible cause: endianness mismatch) at java.lang.ClassLoader$NativeLibrary.load(Native Method) at java.lang.ClassLoader.loadLibrary1(ClassLoader.java:1939) at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1864) at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1825) at java.lang.Runtime.load0(Runtime.java:792) at java.lang.System.load(System.java:1059) at it.unicam.project.Binterpreter.getClassHandle(Binterpreter.java:170) at it.unicam.project.Binterpreter.(Binterpreter.java:100) at it.unicam.project.Test.main(Test.java:12)

lv92
  • 161
  • 3
  • 11

1 Answers1

1

That's because you're running a 32bit JVM on a 64bit platform

joan
  • 2,407
  • 4
  • 29
  • 35
  • I tried to install in my pc the 64 bit jvm but i cannot install it beacuse the os doesn't allow it . Are you sure that the problem is this ? :S – lv92 Mar 29 '13 at 22:23
  • Not sure but you can check the 32/64 architecture of each environment:See http://stackoverflow.com/questions/2062020/how-can-i-tell-if-im-running-in-64-bit-jvm-or-32-bit-jvm – joan Mar 29 '13 at 23:44
  • So the two environments are 32 bits. Could be an eclipse thing (you said that the jar is created wit Eclipse export utility), have you tried to build the jar from the console? http://docs.oracle.com/javase/tutorial/deployment/jar/build.html – joan Mar 30 '13 at 09:56
  • i tried with console (without consider some problem with manifest ) i have the same problem . I tried to download this jar http://dasha.ics.hawaii.edu/~johnson/613f99/modules/04/psae.jar and i called first.jar but the same problem .... :S – lv92 Mar 30 '13 at 10:56
  • But this jar works nicely in my computer: C:\Users\w7\Downloads>java -jar psae.jar hello Hello World hello Do you have the JAVA_HOME variable correctly set? – joan Mar 30 '13 at 11:06
  • i tried the same command and then it works but if i try to load with System.load jvm generates the error that i post above. – lv92 Mar 30 '13 at 11:14
  • Ok, have you tried System.loadLibrary instead of System.load? See http://stackoverflow.com/questions/7016391/difference-between-system-load-and-system-loadlibrary-in-java – joan Mar 30 '13 at 11:28
  • no beacuse it says : "The difference is there in the API documentation. system.loadLibrary(String libname) lets you load from the default path -- The Java library path." The file jar isn't in a default path. And if i try to do that returns me this error : http://pastebin.com/3S6QCXzQ – lv92 Mar 30 '13 at 11:36
  • Just one thing. Are you trying to load a jar with System.load ? System.load is for loading dynamic libraries, no jars. In order to user a jar just put it in the classpath and call it. – joan Mar 30 '13 at 12:03
  • emhm.. yes ,i find this http://stackoverflow.com/questions/194698/how-to-load-a-jar-file-at-runtime to load jar at runtime, thank you for you help. – lv92 Mar 30 '13 at 12:09