Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to set virtual arguments in servlet

 
Rahul Ba
Ranch Hand
Posts: 206
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a simple java program which needs VM arguments while execution. The name of the argument is -DJava.lib.path. Right now I am doing it in eclipse with Run Configuration option.
Now I need to convert the java program to servlet java program for web aplication. My question is how will i set VM arguments in servlet.

Let me know any links or any help.

Thanks in advance.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64838
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That a poor way to pass info to a web app. If you must, you can add them to the server startup. (Which server?)

A better approach would be to use native web application mechanisms such context parameters, or properties files.
 
Rahul Ba
Ranch Hand
Posts: 206
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
no those are VM arguments not simple arguments.
Are you getting me?
 
Himanshu Kansal
Ranch Hand
Posts: 257
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, so you want them to load with the application or be available even before it and not just access them during the runtime of your application?

I think I made a post earlier here too... was it deleted?

Regards
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64838
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Then they'll need to be on the server startup command line.
 
krish laks
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
which server it is?
In server's admin console you will be able to configure VM properties. Which you can get anywhere in the code using System.getProperty("key");
If your server is WAS, I can given steps where to configure this.
 
Rahul Ba
Ranch Hand
Posts: 206
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok, I think I did not clear the question well...

Let me explain a bit more detail
I have a simple java program, which I run through eclipse.Right click on the program Click on Run Configuration. Click on Arguments. Then in VM Arguments I specify
-DJava.lib.path=c:\\DLLfiles then It runs fine.

Now, I want to convert this program to the servlet, then How will I pass this BM argument to my program.
If I do not pass I get this exception java.lang.UnsatisfiedLinkError: no jacob-1.14-M1-x86 in java.library.path

Thanks in advance.

 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64838
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As has been asked multiple times in this topic, what server?
 
Rahul Ba
Ranch Hand
Posts: 206
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's Tomcat 6.0
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64838
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moved to the Tomcat forum.
 
Rahul Ba
Ranch Hand
Posts: 206
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok Here I got the solution but confused on one thing

I kept dll file in System32 folder of windows.

and just put the one line in program as
System.loadLibrary("jacob-1.14-M1-x86"); and it worked well

Now I think there is another alternatives to this work as

If we do not want to put dll in the System32 folder just give absolute path for DLL and access the dll
System.load("C:\\DLLfiles\\jacob-1.14-M1-x86.dll"); This is not working ....why?Anybody know this?
I think even System.load should work...

My second question....Eventually, We want to move this program to run on linux machine. I think in linux, instead of .dll extension we have to specify the .so extension is that right?
So, if I just renamed the .dll file it should work isn,t it?




Expecting kind co-operation.

 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64838
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No. Renaming a DLL will not make it not a DLL.

The correct solution, which I mentioned long ago, is to add the parameter to the startup command of the server. For Windows, that'll be the bat files in Tomcat's bin folder.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic