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.

API java class error

Please login with a confirmed email address before reporting spam

Dear COMSOL,

I am coupling a COMSOL heat transport model with the universal parameter estimation software PEST in Windows. I realize there is an optimization module for COMSOL but it's performance is far superseded by PEST. To achieve the coupling I need the model to read an input file with parameter values (that PEST can modify prior to the model being run) and to write state variables to an output file (for PEST to calculate the objective function and its derivatives). Also, I need to be able to trigger a model run, with the API modifications, from the command line.
To the best of my knowledge, the coupling must be done by the COMSOL API. I have experience with the FEFLOW and Minecraft APIs which are both easy to use, in particular the former. Unexpectedly, I am struggling a lot with the COMSOL API.
Here is what I have done so far:
I have exported the cylinder_conduction example model to a java file and compiled it with Eclipse as a sort of proof of concept (the feeder_clamp model is nowhere to be found). The code runs perfectly in Eclipse and makes a connection to the COMSOL server that I have set up (which can be checked in the server log). I use the server connection to check that the model code is actually being run.
However, loading the class file directly into COMSOL produces an error:

Error running Java Class
-Detail: Error_running_java_class

If I run the class file from the command line I receive an identical error. I have included the installation paths of the jdk and the COMSOL home directory in the Windows path variable.

On a sidenote: If I use the standalone option (ModelUtil.initStandalone(true)) as suggested in the API reference, I get the following error: "Input length must be multiple of 16 when decrypting with padded cipher".

I am at my wits end here. I can run the code in Eclipse which is some sort of workaround because I can trigger it from the command line but it is definitely not an optimal way of implementing the API module. Can anyone help me here?

Best regards,
Søren


1 Reply Last Post May 18, 2016, 6:25 a.m. EDT
COMSOL Moderator

Hello Søren Erbs Poulsen

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: 8 years ago May 18, 2016, 6:25 a.m. EDT
I just got this error too

Error running java class.
- Detail: Error_running_java_class


and eventually figured out what was wrong. In my case I forgot to change the %PATH% environment variable (on Windows) from Comsol 5.1 to 5.2 when upgrading. So "comsolcompile" still worked, and the ".class" file loaded into 5.2, and almost everything worked, but then the model.mesh("mesh1").export(path); command caused this error. (It doesn't seem to be a standard Java Exception, because my code would have caught that.) So it's 99.5% backwards-compatible.
I just got this error too [QUOTE]Error running java class. - Detail: Error_running_java_class [/QUOTE] and eventually figured out what was wrong. In my case I forgot to change the [b]%PATH%[/b] environment variable (on Windows) from Comsol 5.1 to 5.2 when upgrading. So "comsolcompile" still worked, and the ".class" file loaded into 5.2, and almost everything worked, but then the model.mesh("mesh1").export(path); command caused this error. (It doesn't seem to be a standard Java Exception, because my code would have caught that.) So it's 99.5% backwards-compatible.

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.