Loading an external class folder in eclipse - java - java

I am trying to use the LPsolver on a project I am working on. (it contains both jar and DLLs).
When I ran it locally it worked (System.loadLibrary("lpsolver"))
But now I am trying to upload it to an amazon server which is running tomcat.
I can't get the tomcat server to load class library correctly.
Tried to include it in all kind of different locations and loading it but non seemed to work.
Any idea how I can accomplish it ?
Thanks!
EDIT:
Tried lots of stuff I found on the web, mainly ways to include the class library I need inside the project and not a reference through the local vars.but my project does not seem to recognize it. Also wanted to upload it to my amazon web server ( to system32) but I guess because I use the free version that option is not included...

Related

saving images to static folder require refresh/reload the server to implement changes

I'm trying to save/load images in the resource/public/images folder of my spring boot project, but I faced a problem that all changes to this folder require to restart of the tomcat server but I need to implement all changes without restarting anything to avoid production problems.
I searched for a solution on the Internet and I reached to use additional tools that should be a solution to my problem so I used devtool dependency but I still have the problem.
I'm not looking for local changes on my IDE but I need a solution that can be work everywhere.
First of all the solution that you are looking for is not possible and should not be design like that. Think of it, when your application would be ready, it would be a jar/war (an archived library) deployed on production and its not expected that your jar/war has to have changed at runtime. The correct solution would be, on the same server where you would deploy you app, you can create a folder (may be in same directory where you place your jar) and in this folder you can manage your images and can be read from there. So try by creating a folder outside your app.
And for your local, devtool is basically consume the latest changes from code and helpful only for development as you don't want to restart the server every time when you make any changes in the code.

SO libraries not loading when running as Java web application

I searched a lot in So. But could not find a proper solution. Here is the problem
I have some .so files to load in my java application.
I created a Java class with main method and loading it using System.load();
System.load("/home/myfolder/TFS-SDK-11.0.0/redist/native/linux/x86_64/libnative_auth.so");
System.load("/home/myfolder/TFS-SDK-11.0.0/redist/native/linux/x86_64/libnative_console.so");
And then my Java codes. When I run the class as Java application, it is working fine.
Then I added the same code in my Java web application. And I run it in tomcat. But It is showing some error
Exception in thread "main" java.lang.UnsatisfiedLinkError
I found that this is because it is not loading the library files.
When I searched in google, I found some solutions but it didnt help me. I tried adding the so file location in
setenv.sh, catalina.sh in JAVA_OPTS. But none worked.
Some solutions I don't even understood.
Can someone give the step by step proces of
Where to put the so files in tomcat?
Which file I should edit and What should I add?
I searched a lot. But most answers I don't understand.
When you run your app in a web container such as Tomcat, your main method will NOT be called.
If you want to load these libraries when the container starts, then I'd suggest using a ContextListener.
Try googleing "context listener example in java" - you'll get plenty of hits and plenty of examples to follow.
You will probably also need to add these libraries on to your Unix Library Path. It's usually convenient to do this in your tomcat start up script. The name of the library path variable is unix flavour dependent, so I can't tell you what that path is I'm afraid.

How to avoid installing the configuration files of a swing application in every computer in the network?

I have a swing application that is installed in the server, and to access it, I have created a short-cut in every computer in the network, and it's working just fine. The application uses jrxml files to generate documents, and they are packaged in a folder called Cycloplan and its working fine, but I still have some technical issues, in which every time I make some updates in the configuration files, I have to go to every computer and paste the Cycloplan folder to it, so I am looking for a method to avoid this operation when an update shows up. please help.
Package the .jrxml files into Jars and deploy the lot using Java Web Start. They will be updated automatically when the Jar is updated.

Apple Flat Package (pkg) from Java

I've been doing some research into how to make Apple flat packages from a Java webapp. There doesn't seem to be much out on the subject. I found a website that details the contents of a flat package but it seems like a bit of a project to start from scratch. Anyone have any experience building PKGs? Does anyone know of any libraries to aid in the process?
EDIT:
It seems I may not have been clear in my request. My goal is to have users go to a website that requires them to enter some information. After they've entered their information my code would create a PKG for them that contains some information about them. For example, maybe the postinsall script would run the command "say 'Hello USERNAME_THEY_ENTERED'". Silly example but it's the general idea. The user would then be able to run the PKG and the install that takes place would be customized with their information.
Why would you want a web application in a pkg file? What servlet container accepts pkg files?
Web applications are meant to be packaged as WAR or EAR files (since we are talking about Java) and to be deployed on a servlet container like tomcat, jetty, websphere, glassfish, jboss, ... running on a server. The client computer then uses a browser to access to web application on the server.
PKG files can be compared to MSI files. These are meant to facilitate the installation of software (or libraries) on a client. For that the website you linked seems to have valid information.
I am not sure why you want to do that for a webapp but we have done it for a standalone Java App (which actually was a collection of webapps including the server).
If this works for you, try to prepare your application.app folder using jarBundler. It provides an Ant task that will make things much easier.
If this does not work for you (as unfortunately was the case for us), then you have to prepare the application.app folder by hand and script adding the java resources. Start from an existing app, generated with Jar Bundler for instance, and adjust accordingly.
Then you need to install XCode and get PackageMaker. This app has a GUI but you really need to read the doc. The biggest issue we have met is that you cannot script the package build process.
I need to add that, unless you need to run some post-install scripts, building a DMG is probably much easier.

Package an application including java war file, Tomcat, DB

i have a java based web application, i have the source code as well as the war file, the application uses mySql and need some web server like tomcat all to be added to some package that can be directly installed on window and linux machines directly..
i need to setup DB, WebServer, and app in one go. Would be great if it can create services for all as well.
is it possible???
i mean the user should just give the location to store and everything should get stored in one go, is it feasible? and if yes please guide me how to do so...
In short: Yes, it is.
Projects like XAMPP are already following that approach. All relevant software components are inside a single ZIP file which you can extract to an arbitrary location on the user's harddisk. All configuration then uses relative paths when referencing files.
So essentially, you will have to put in a little effort in advance to make the "installation" as easy as possible. Maybe you can simply build upon a project like XAMPP and use the infrastructure already provided?

Categories

Resources