I created a project in java and made a jar.
I did this using maven on a Linux OS.
My problem is the jar compiles and works fine on Linux.
But when it comes to running it on windows it doesnt work really well. As in a jframe will appear but functions wont work.
I was looking at
swtjar
But i hasnt been much help. Do jars not run on different os.
Can anyone point me in the right direction I have no idea why this is.
Thanks
edit I get a NoClassDefFoundError for my gui
It seems that you are mixing Swing components and SWT widget together. Do not do that unless you have special reason. For SWT applications, it do have some difference between different OS as this is the goal.
when you get a NoClassDefFoundError , there seems to be an problem with your classpath.
check if all files on classpath really exists.
Related
I've searched for this answer and I find things that are similar for Windows, but not for Mac. I have an old program that is used on Windows, but not Macs yet. I did not write it, but I have decompiled it to get the code. It looks like it shouldn't be that hard to make it work on Mac, but I want to make a nice installer so my users will want to try it. I have only recently gotten back into the programming game, so I am learning.
I have been investigating how to make a Windows installer that detects the Java version and then installs the correct one if necessary. Is there such a thing for a Mac installer? I have never worked on a Mac so I do not know how its guts work. I have a friend with a Mac who is willing to beta-test for me. I have one lib file that the program needs, plus an icon file. The lib file may need to be changed in the future. It's just a text file. So I would like the icon and the lib file to be part of the package.
I've seen that there is a Java app bundler for Mac, but it's not obvious that it a) checks the Java version and installs the right one or b) that I can include other files in the bundle.
I appreciate any guidance you can give me.
I developed a Java Swing Application. It was developed using Netbeans in OSX. It runs perfectly in nix but when it comes to windows, I get this exception:
NoClassDefFoundError: org/jdesktop/beansbinding/Property
Tried many things like removing and adding libs to the class path again. Googled a lot in vein. How can I fix it?
Problem partially solved. Built the same project in windows and its working in windows. The jar built in nix works fine in nix but shows this error in windows.
Unix (and OSX) have different classpath separator than windows (: instead of ;), check out your startup script or command line parameters.
AS you have already mentioned, issue is with the missing jar file in class path.
Try printing the java class path from code and look out for the missing jar file.
System.out.println(System.getProperty("java.class.path"));
org.jdesktop.beansbinding.Property is part of jsr296, which no longer supported in newer versions of NetBeans. See Why can't I find Java desktop application in Netbeans 7.1 for more.
Once I had the same problem but not with swings with jdbc. I tried a lot and got the solution.
First you make sure that all things said in google and the above answers are done. Still if the problem persists means delete all the class files created before and rerun the project once again, it ll work. Notify me if it works.
I encountered a strange situation and I'm struggling myself, trying to understand which is the problem.
I developed a Java application under Eclipse using Swing and jdbc.
I exported an executable jar file, created using Eclipse under Windows.
When I execute the exported file under Linux, everything is working fine, (both the gui and the database access) except that the JDialogs that sometimes are displayed, are not showing anymore in Linux.
If I generate the jar again, under Linux, (without modifying anything in the source code) JDialogs begin to work again.
What's the reason for this?
It seems that the problem isn't related to my source code, so do I have always to generate again an executable jar for every different operating system?
And again, if it is a problem related to the jar building process, why the only problem occurs with JDialogs?
I hope to be clear
thanks in advance to all
Of course you don't have to build on every platform. The idea is to make it once, run everywhere. Are you using the same versions of JDK/JRE on the Windows and Linux machines? Versions of other tools, e.g. Eclipse, Ant?
There are some Components in java swing that have bugs and may not be platform independant.
Perhaps JDialog is one of those bugs.
I made a simple java program that sends bytes to the parallel port, which uses a .dll along with two other classes (pPort.java and ioPort.java) to accomplish it, and it works perfectly fine.
However, I started making another program on NetBeans IDE which has a similar function. It compiles perfectly, but when I run it I get:
Exception in thread "AWT-EventQueue-0" java.lang.UnsatisfiedLinkError: parallelporttimer.ioPort.Out32(SS)V
From what I understand, it's failing to call the .dll file I put on System32. But I don't understand why, since the other program, which is basically the same but made manually without any IDE, runs fine. Do I have to specify something in NetBeans for this to work? Any help with this would be greatly appreciated.
DLL needs to be in the path or current working directory in order to be loaded.
I'm guessing when you've ran your program without IDE the latter was the case. When you run it from within NetBeans "working" directory is likely netbeans/bin folder, so DLL can't be found. Add its location to path and you should be good to go.
I don't do Netbeans, but it sounds like that Netbeans maintains its own java.library.path. Best what you could try is to specify it yourself as VM argument:
-Djava.library.path="c:/path/to/dll/files"
An UnsatisfiedLinkError message typically indicates that the library path is set but does not include the library that you are trying to load. On Windows platforms, you should extend the PATH using
PATH = %PATH%;C:\path_to_dll_file
On UNIX platforms, you should extend the library path using
setenv LD_LIBRARY_PATH mylibrarypath
However, as far as I can remember (I'm not under Windows), System32 is in the PATH so I suspect NetBeans to overwrite it by settings its own PATH.
To solve this on NetBeans, you might want to check http://wiki.netbeans.org/DevFaqNativeLibraries which is mentioned in this message from Wade Chandler, a NetBeans Dream Team Member ;-)
PS: You can also use the java.library.path system property but keep in mind that this system property only works to resolve the immediate native library that you are loading in your code. Loading of other dependent libraries is left to the first library. The JNI library that you load will rely on the OS dependent way to resolve its references (this applies to the solution of the FAQ too IMO so I'm still not 100% convinced its a good solution).
Have you looked into the two classpaths for both programs (standalone and IDE) ?
In my case the cause was not the missing library, but the use of 64 bit Java JDK as default java platform for Netbeans.
(It did not help to add the "-d32" flag.)
The problem was solved by:
Adding a 32 bit java platform to Netbeans (Menu: Tools/Java platforms) and
Assigning it as the platform for the project (Project properties/Libraries/Java Platform).
I've done several projects and packaged them into jar files, but I've noticed that my jar files run much more slowly than in my IDE.
I use Eclipse to compile and run my programs. In Eclipse, I have everything working. When I package my project as a runnable Jar and execute it by double-clicking, everything still works. But when I have animation, the program runs extremely slowly. Instead of 30 frames per second in Eclipse, I now get about 2 frames per second. The animation is very laggy.
Interesting thing is, when I run the same Jar from the command prompt (java -jar MyCode.jar), the lag disappears and my program works as normal.
I currently have no idea what's causing this problem. My computer is running Windows Vista. I'm using the latest version of JRE and JDK. My program contains an animation, nothing fancy.
Thanx
Solution:
There were several different versions of Java on my computer and an incorrect version was used.
The version of java.exe that comes with Windows is very out of date.
By changing the association of the .jar extension to the more recent JVM you should see much improvement.
You may also consider whether any running antivirus software is affecting performance. Some software treats .jar files as the .zip archives that they are and scans accordingly. Their shell integration might explain the difference between double-clicking and command line as well.
Probably you have associated the double click with some "bad" JVM version.
What I would do is to use processxp from SysInternals to see what's the interpreter your app is using. Probably is only matter to change it to use the same as the command line and the eclipse.
Check that and see if both uses the same JVM ( there's a column names command line in ProcessXP, compare that value )
I hope this helps.