Java Jar Looking for Windows SWT Library on Linux - java

A year ago, I created an Eclipse project that was developed on Windows and deployed to Linux. I used SWT, and I was able to get it running on Linux with the appropriate SWT jar. No problems.
Recently, I started a new project with the same MO: develop on Windows, deploy to Linux, use SWT. I used the same project structure as the project that worked, but it won't work on Linux. When I try to run the new project on Linux, it hits me with an UnsatisfiedLinkError:
Exception in thread "main" java.lang.UnsatisfiedLinkError: Could not load SWT library. Reasons:
no swt-win32-4924r25 in java.library.path
no swt-win32 in java.library.path
Can't load library: /home/hmartin/.swt/lib/linux/x86_64/libswt-win32-4924r25.so
Can't load library: /home/hmartin/.swt/lib/linux/x86_64/libswt-win32.so
What looks peculiar to me is that it seems to be looking for the Windows version of the SWT jar, and I don't understand why that could be. I've fiddled with project preferences, build paths, build.xml, manifests, etc.
I do have a manifest that is supposed to tell the application where its SWT library is (in the same directory as the application jar), but I suspect that my project doesn't know it exists. With the working project I made a year ago, I remember being able to have Eclipse generate a manifest file upon export, and that's what I did. With this (broken) project, I am not able to generate a manifest file nor do I have the option of selecting one from the workspace upon export. This time, I just made a manifest file myself, followed the naming conventions, and hoped the magic happened. The magic has not happened.
Help, suggestions, recommendations, etc. are much appreciated.

After playing around with a test project and export settings, I discovered that the cause of my problems was one single check box on the JAR export screen: "Export generated class files and resources". I had this box unchecked, which meant that (for some reason) Eclipse wouldn't show me the options to generate or select a manifest. With that box checked and manifest selected, the new project now runs on the target platform.

Related

Java Application launch failed. Check Console for possible error messages related to "/Users/X/Project.jar"

Trying to open .JAR file on macOS Ventura intel base laptop running java 8 351. GUI game was built using IntelliJ, Java jdk 19 and JavaFX 19. Getting a console error message with no console appearing. GUI game works perfectly inside IntelliJ, included right libraries and module paths. When building artifacts "exporting jar executable" I get prompted with this error message whenever I'm trying to open it.Error Message
Solutions tried to find where the problem is with no avail
I tried creating simple javafx program and building artifacts.
Built project with different java jdks.
Built project with visual studio code and eclipse.
Went through the same steps on a older macOS
I'm suspecting its a java jre error, any tips on how to fix this problem?
You Should Make FXML files in one package and go to project structure -> Modules -> sources. Then select your package of fxml files and mark it as resource.
Pic Of Example Mark Module As Resource
Then Re Arrange getClass().getResourse("") code lines using under scenario
Pic Of Example Direction to resources
The "./" Directly direct into resources.
Jar files cannot read fxml files until you make them as resources

Clarification for exporting a LibGDX game as an applet

I'm trying to follow the guide to export my project as a Java applet.
My project, as seen in Eclipse, has three directories:
Game
Game-Android
Game-Desktop
They were created using the UI Setup tool. The guide at http://www.thesecretpie.com/2011/05/being-like-minecraft-or-how-to-run-your.html is confusing and I don't understand these points:
Next step: add a new file called HelloWorldApplet.java (in the same
directory as other source files).
"The same directory as other source files". Well, I have three directories and they all have a source folder. In which of these three am I supposed to put this file? I tried placing it in Game, but Eclipse is unable to resolve com.badlogic.gdx.backends.lwjgl.LwjglApplet. If I put it in Game-Desktop it seems to be OK, but I'm not sure.
Create a directory called applet in your project dir.
Again, in which of my three directories?
Just export the whole project as jar in Eclipse
I can export a JAR for Game, Game-Android, or Game-Desktop. Which of these?
Related:
I happen to be using the JRuby JAR in my game to run some ruby scripting logic. Do I have to do something specific about it?
That blog is little old. For example, the JOGL backend is gone from recent version of Libgdx (so you don't need to worry about switching to the LWJGL backend). Also, the current LWJGL bundled into Libgdx is 2.9.0 (hopefully that doesn't change too much, though).
I believe the instructions are effectively packing up the "desktop" build of your app into an Applet (as the desktop is the only build that use the LWJGL backend), so assume Game-Desktop is the "same directory" that its talking about.
Thus, you should export the .JAR from your Desktop project.
On a related note, there is another way to run your game on the web, using the GWT backend. Check out the Setup & Running page (where its called "HTML5"). There are a bunch of caveats on using the GWT backend (not all Libgdx APIs work over there). (Hmm... I doubt this will work with the JRuby JAR, so probably not worth spending too much time on that.)

Regarding executable jar file

I have developed an application and mostly it is a Swing based application. I have made the executable JAR of the whole project. Now when I click that JAR it gets executed and my project starts and the Swing window shows up as usual. But when I try to execute that same executable JAR on another system it doesn't get executed. Please advise how to solve this..!!
The reason that might be that the JRE may also not be installed on his system or the class path was not set..! Please advise how to execute the same JAR on his system too.
Are you working with eclipse? Maybe the other system doesn't have the JRE7. If this is the case, you have following possibilities:
Update the JRE on the other system
Create a new project in eclipse and select JavaSE-1.6 at "Use an execution environment JRE"
This compiles your project JRE6 compatible. However, you have to put more details to your question.
Have a look to:
http://launch4j.sourceforge.net
http://jsmooth.sourceforge.net
these wraps your jar into an executable,which makes easier to distribute your app,taking care of things as setting the classpath and installing the JVM if not present.
Your questions is missing some details.
Please, specify output that you get when running your application on your friend's machine.
Otherwise it is hard to advice something.
More details are also welcome: jdk/jre version, OS version, build scripts, etc.

RCP's exec launcher can't find companion shared library on launch, but starts with click on org.eclipse.equinox.launcher_1.2.0.v20110502.jar

I'm building an Eclipse RCP application against Eclipse 3.7.1 and Java 1.6.
I'm also using Tycho to build, and have set up my RCP according to the Tycho tutorial from the EclipseCon 2011, to which I've stuck slavishly, apart from project names.
The application builds fine up until I get to Step 5 (adding a p2 repo, then adding a .product file. Well, it still builds fine, and everything is where it should be, but I cannot start the RCP by clicking on the .exe file from the repository in the workspace.
All I get is the old dreaded "The [RCP] executable launcher was unable to locate its companion shared library" error popup.
First of all I thought I might have set up the CLASS PATH incorrectly, but when I open a console and type javaw or java -version anywhere, it all works.
Also, when I go to the pluginsfolder in the p2 repository for the RCP in the workspace, and double-click on org.eclipse.equinox.launcher_1.2.0.v20110502.jar, the RCP starts, albeit without the splash screen.
This must surely mean my Java set up is correct, and it's not a class path problem?
I'm not sure where this problem might lie (I have a plugin, a feature, a product, a repository, and a parent package with the main pom), so if you let me know your suspicions where the error might come from, I'll be more than happy to post respective XML, build.properties, screenshots and what have you. Unless this is a common error with a common solution.
Many thanks in advance!
Oh yea: Windows 7 (64-bit), JDK and JRE both 64-bit as well, Eclipse EE 3.7.1 (I chose that because it contains the most plugins I'll need later by default).
UPDATE
I'm attaching my CLASS PATH Settings for reference.
User variables
CLASS PATH: C:\Program Files\Java\jdk1.6.0_30;.;
System variables
JAVA_HOME: C:\Program Files\Java\jdk1.6.0_30
Path: %JAVA_HOME%\bin;
UPDATE 2
When I let Tycho create a ZIP file in the p2 repository, and copy that from the repo to another location, unzip it and run the .exe, the application starts without problems. So I guess this query is partially solved, but I'd still be interested to hear why I wouldn't be able to start the application from the repository...
Today I came across the same issue. I guess you could find the solution here: https://bugs.eclipse.org/bugs/show_bug.cgi?id=176084
In short, the problem in my case was, that the org.eclipse.equinox.launcher_1.2.0.v20110502.jar must be unpacked in the plugins folder under the folder name: org.eclipse.equinox.launcher_1.2.0.v20110502
... hope that helps!
In my case the error The [RCP] executable launcher was unable to locate its companion shared library was because my path was too long.
Same issue I was facing from yesterday. Today, I have changed path of project(git clone) and build it and able to run RCP executable.
I think this issue was because of path too long.

Configuring Netbeans with JNotify

I'm trying to use the JNotify library along with netbeans, however I don't know the proper way to configure it. Everything I try, the lines involving jnotify (eg. import net.contentobjects.jnotify.*) are underlined in red. Google seems to show nothing helpful regarding netbeans with jnotify, although I assume it's something simple like adding it to the classpath. I've tried adding the .jar as a library for compile & for run, no go.
The line i've been provided for running my app from the jnotify page:
-cp jnotify.jar -Djava.library.path=.
should I be using this as my compiling options or VM run options or both? seeing as I don't want to have to distribute my app with a .dll or .so file or the jnotify .jar.
Everyone on this site recommends using such and such a library, but they don't realize how hard they can be to set up (jnotify,boost,curl), and most who recommend them have probably never even used them themselves.
You're right, you have to add every library you use in your programs, into the projects classpath:
Click on the project node in your 'Projects' window. It should by default have a node called 'Libraries'.
Right click this node and select 'Add JAR/Folder'
Locate the JNotify.jar on the file dialog and press 'Open'.
Refresh your project, or just give netbeans some time to rescan the classpath, and you should be good to go.
There definately is something wrong with your classpath. While the above is exactly how you set the classpath when running a Java program, its different for a NetBeans project.
Follow these articles on how to add extenal jars to a NetBeans project.

Categories

Resources