wood burning stoves 2.0*
The moose likes Tomcat and the fly likes How to set virtual arguments in servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "How to set virtual arguments in servlet" Watch "How to set virtual arguments in servlet" New topic
Author

How to set virtual arguments in servlet

Rahul Ba
Ranch Hand

Joined: Oct 01, 2008
Posts: 205
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

Joined: Jan 10, 2002
Posts: 60785
    
  65

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.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Rahul Ba
Ranch Hand

Joined: Oct 01, 2008
Posts: 205
no those are VM arguments not simple arguments.
Are you getting me?
Himanshu Kansal
Ranch Hand

Joined: Jul 05, 2009
Posts: 257
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


Experience and talent are independent of age
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60785
    
  65

Then they'll need to be on the server startup command line.
krish laks
Greenhorn

Joined: May 18, 2007
Posts: 27
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

Joined: Oct 01, 2008
Posts: 205
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

Joined: Jan 10, 2002
Posts: 60785
    
  65

As has been asked multiple times in this topic, what server?
Rahul Ba
Ranch Hand

Joined: Oct 01, 2008
Posts: 205
It's Tomcat 6.0
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60785
    
  65

Moved to the Tomcat forum.
Rahul Ba
Ranch Hand

Joined: Oct 01, 2008
Posts: 205
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

Joined: Jan 10, 2002
Posts: 60785
    
  65

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.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: How to set virtual arguments in servlet
 
Similar Threads
How to debug a remote application using Eclipse IDE.
Setting javac options in Eclipse
how can I provide vm arguments to a java program while executing from command prompt ?
Using Eclipse
How do I specify the /3GB switch in the java VM arguments