Note: This discussion is about an older version of the COMSOL Multiphysics® software. The information provided may be out of date.

Discussion Closed This discussion was created more than 6 months ago and has been closed. To start a new discussion with a link back to this one, click here.

problems when running a .class file from the command line on linux

Please login with a confirmed email address before reporting spam

Hello,
I have a java application which can be controlled using command line arguments (if it is started from the Desktop, or with no command line args, it pops up a dialog where I can give these command line args). It runs fine on Windows either from the Desktop or from the command line. It runs fine on linux from the COMSOL Desktop, but when I run it from the command line like this:
java -cp "/usr/local/comsol44/plugins/*:." MyApp -cmd -line -args
then I get the error message below. If I run it using
comsol batch -inputfile MyApp
then it runs fine (and I can provide the lacking command line args in the dialog that it pops up automatically). But I would like to be able to provide command line arguments directly on the command line, which I can not do using 'comsol batch'.

What should I check? Set LD_LIBRARY_PATH to something?
Thank you

Exception:
java.lang.UnsatisfiedLinkError: com.comsol.nativejni.geom.Geom3.createGeom3(Lcom/comsol/nativejni/CPointer;I)V
(rethrown as com.comsol.util.exceptions.FlException)
Messages:
com.comsol.nativejni.geom.Geom3.createGeom3(Lcom/comsol/nativejni/CPointer;I)V

Stack trace:
at com.comsol.nativejni.geom.Geom3.createGeom3(Native Method)
at com.comsol.nativejni.geom.Geom3.<init>(Unknown Source)
at com.comsol.nativemph.geom.Geom3.<init>(Unknown Source)
at com.comsol.model.method.GeomSequenceMethod.setEmptyGeom(Unknown Source)
at com.comsol.model.internal.impl.GeomSequenceImpl.doSetEmptyGeom(Unknown Source)
at com.comsol.model.internal.impl.GeomSequenceImpl.setEmptyGeom(Unknown Source)
at com.comsol.model.method.GeomSequenceMethod.doInitialize(Unknown Source)
at com.comsol.model.internal.impl.GeomSequenceImpl.doInitialize(Unknown Source)
at com.comsol.model.internal.impl.ModelEntityImpl.initialize(Unknown Source)
at com.comsol.model.internal.impl.GeomListImpl.doCreate(Unknown Source)
at com.comsol.model.internal.impl.GeomListImpl.a(Unknown Source)
at com.comsol.model.internal.impl.GeomListImpl$1.a(Unknown Source)
at com.comsol.model.internal.impl.GeomListImpl$1.execute(Unknown Source)
at com.comsol.model.clientserver.ClientManager$1.call(Unknown Source)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:744)

3 Replies Last Post 19 ago 2016, 05:45 GMT-4
COMSOL Moderator

Hello

Your Discussion has gone 30 days without a reply. If you still need help with COMSOL and have an on-subscription license, please visit our Support Center for help.

If you do not hold an on-subscription license, you may find an answer in another Discussion or in the Knowledge Base.


Please login with a confirmed email address before reporting spam

Posted: 9 years ago 20 ago 2015, 14:07 GMT-4
Hi, could you solve this problem?
Thanks
Hi, could you solve this problem? Thanks

Please login with a confirmed email address before reporting spam

Posted: 8 years ago 18 ago 2016, 09:55 GMT-4
I am having the exact same problem. Any progress?
I am having the exact same problem. Any progress?

Please login with a confirmed email address before reporting spam

Posted: 8 years ago 19 ago 2016, 05:45 GMT-4
As a temporay workaround i write the arguments to be passed to the .class file to an "args.json" file. In python it looks something like this,

# HACK: Dump args as json.
with open("{}/{}".format(model_dir, "args.json"), 'w') as outfile:
json.dump(args, outfile)
# Invoke comsol batch processing.
subprocess.call(args)

where model_dir is the current working directory. I can then load them using the following hack:

public static void main(String[] args) {
# HACK: Read args from json.
if(args == null) args = JsonUtils.parse_arr((JSONArray) JsonUtils.parse_json("args.json"));
...
}

where the JsonUtils method are just some static helpers that make the JSON parsing less painfull.
As a temporay workaround i write the arguments to be passed to the .class file to an "args.json" file. In python it looks something like this, # HACK: Dump args as json. with open("{}/{}".format(model_dir, "args.json"), 'w') as outfile: json.dump(args, outfile) # Invoke comsol batch processing. subprocess.call(args) where model_dir is the current working directory. I can then load them using the following hack: public static void main(String[] args) { # HACK: Read args from json. if(args == null) args = JsonUtils.parse_arr((JSONArray) JsonUtils.parse_json("args.json")); ... } where the JsonUtils method are just some static helpers that make the JSON parsing less painfull.

Note that while COMSOL employees may participate in the discussion forum, COMSOL® software users who are on-subscription should submit their questions via the Support Center for a more comprehensive response from the Technical Support team.