3

I downloaded a java app (a desktop LogCat viewer from android logs) and am trying to run it. My problem is that I amm getting an error that seems to imply I cannot run a 32 bit java app on a 64 bit jvm. The stack trace is below.

I need to point out that I cannot change the source. I don't have access to it. I need to know how I can configure my jvm to run the jar. I'm running in Windows 7.

> java -jar LogcatOfflineViewer_20120505.jar
Exception in thread "main" java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:58)
Caused by: java.lang.UnsatisfiedLinkError: Cannot load 32-bit SWT libraries on 64-bit JVM
        at org.eclipse.swt.internal.Library.loadLibrary(Unknown Source)
        at org.eclipse.swt.internal.Library.loadLibrary(Unknown Source)
        at org.eclipse.swt.internal.C.<clinit>(Unknown Source)
        at org.eclipse.swt.widgets.Display.<clinit>(Unknown Source)
        at com.logcat.offline.UIThread.runUI(UIThread.java:112)
        at com.logcat.offline.Main.main(Main.java:6)
        ... 5 more
ewok
  • 20,148
  • 51
  • 149
  • 254

2 Answers2

9

A JAR is not 32-bit or 64-bit, it can run on either JVM.

However, a native shared library is either 32-bit or 64-bit and it can run only with a JVM with that bitness. This is a limitation of the way application run on Windows and Linux (and every other OS AFAIK) There is no way to load a 64-bit library on a 32-bit JVm or visa-versa. You need to match your sahred libraries versions with your JVM.

Peter Lawrey
  • 525,659
  • 79
  • 751
  • 1,130
  • 1
    @Krishna This is a limitation imposed by the OS and to some degree is fundamental to the difference between 32-bit and 64-bit applications. – Peter Lawrey May 28 '14 at 12:57
  • so there is no way of executing any 32 bit application on 64 bit mac os is it? because i need to execute that application on 64 bit mac i mean that swt application. can u give me some idea – Kishan Bheemajiyani May 28 '14 at 12:59
  • @Krishna You can't run a 32-bit application with 64-bit libraries. Most 64-bit OSes have 32-bit emulators and 32-bit libraries as well. – Peter Lawrey May 28 '14 at 16:15
  • they is there any indirect way to do this? – Kishan Bheemajiyani May 28 '14 at 18:03
  • @Krishna Yes, you can have a 64-bit JVM talk to a 32-bit JVM running a 32-bit DLL/shared library. You can also have a 32-bit JVM talking to a 64-bit JVM running a 64-bit DLL/shared library. i.e. use RMI or RPC/JMS. – Peter Lawrey May 28 '14 at 20:35
  • Please can u explain how to do that? and where i can find this DLL/shared Library. ? – Kishan Bheemajiyani May 29 '14 at 05:02
  • @Krishna I am assuming you have a DLL/Shared library already as this is the point of the question. If you don't know where to find it, you don't have a problem. ;) – Peter Lawrey May 29 '14 at 07:52
  • so is there any changes that i have to make for that? and tell me na how to do it? – Kishan Bheemajiyani May 29 '14 at 08:36
  • @Krishna I don't understand what your specific problem is, so I don't know what you need to change. I suggest you write a new question, describing what you are doing, what the problem is, including any code and errors, and what you have tried. – Peter Lawrey May 29 '14 at 08:46
  • Well i need to Run Dj native swing application in mac. but thing is that its giving error of cant load 32 Jvm Libraries into the 64bit jvm i solved that prob with windows but still not solved for Mac. – Kishan Bheemajiyani May 29 '14 at 08:47
  • You need to obtain the 64-bit library to run in a 64-bit JVM. Or you need to learn how to use RMI between two processes. – Peter Lawrey May 29 '14 at 08:51
  • Can u give me link for swt 64 bit library for mac. ? and ya or please give me link for RMI – Kishan Bheemajiyani May 29 '14 at 08:53
  • @Krishna Are you using Swing or SWT because you shouldn't be using both AFAIK. I suggest you use google to find these. – Peter Lawrey May 29 '14 at 08:56
  • i have google a lot for this. yes i am using swt libraries. i solved everything just remaining for mac only. but m not able to find that :( – Kishan Bheemajiyani May 29 '14 at 09:00
  • still have not find anything that help me with mac os all time when i run that its giving error that swt version 4.3 or later require or sometime its giving that 32 bit libraries cant be load in 64bit jvm and all – Kishan Bheemajiyani May 29 '14 at 09:04
  • Here the link http://stackoverflow.com/questions/23707562/dj-native-swing-browser-in-java-swing-for-mac – Kishan Bheemajiyani May 29 '14 at 09:46
1

I had a similar problem which I solved ensuring to run my jar on the correct jvm by giving the full path in the command prompt (I had already 2 versions of java in my system)

It seems that you can also use the -d32 or -d64 switch, even if in my system that didn't work (see this and other alternatives is How to run 32-bit Java on Mac OSX 10.7 Lion )

Community
  • 1
  • 1
lib
  • 2,918
  • 3
  • 27
  • 53