0

I am trying to execute some published java code that converts an SBML (Systems Biology Markup Language) file to three text files. Running libSBML code requires linking to a jar file "libsbmlj.jar". The code works in Eclipse, but I would like to run the code in Powershell for ease of running my biological simulation (all other commands in the workflow work in Powershell). When I try and run the code in Powershell using the following commands:

javac ToyGenInput.java
java ToyGenInput

as specified in the code instructions I get the following error:

Error: unable to load the file libsbmlj.jar.  It is likely
your LD_LIBRARY_PATH environment variable or CLASSPATH variable
does not include the directory containing the libsbmlj.jar file.

I have tried adding a separate environment variable "CLASSPATH" (I believe LD_LIBRARY_PATH is for Unix-based systems) and adding the folder path to the existing "PATH" variable, however I still get the same error. Copying the .jar file to the current directory also did not work. Does anyone have any suggestions on how to fix this?

Thank you for your time!

NB: Link to the published code: http://www.comp.nus.edu.sg/~rpsysbio/pada

The file "ToyGenInput.java" consists of the following code, calling a secondary file "SBML2SPA.java":

public class ToyGenInput{
    public static void main(String[] args){
    SBML2SPA ss=new SBML2SPA("./models/toy/toy.xml"); 
    ss.printODEs("./models/toy/");
    ss.printPar("./models/toy/");
    ss.printVar("./models/toy/");
    }
}
mhucka
  • 2,143
  • 26
  • 41
Laura
  • 89
  • 8
  • The CLASSPATH variable is tricky. Note on [this](https://docs.oracle.com/javase/8/docs/technotes/tools/windows/classpath.html) website, look for the classpath wildcards, as they are needed for jar files – Scott Twombly Jun 08 '16 at 12:26
  • You can pass classpath info on the command line of the Java command. Have you tried that? – rrirower Jun 08 '16 at 12:49
  • Initially, forget about Powershell. Get it working for the command prompt first, once that is working then move on to powershell. – Jimbo Jun 08 '16 at 12:51
  • Scott Twombly - I tried adding this in the following formats "C:\..\java;java/*" and "C:\..\java/*;java" in System as suggested in your link (thanks!) but this didn't work. Am I making a stupid mistake? (Sorry, java newbie here!) – Laura Jun 08 '16 at 14:04
  • I suppose using an IDE is out of the question for exporting an executable jar? Eclipse and IntelliJ make it very easy to do this. – Ashwin Gupta Jun 08 '16 at 14:25

1 Answers1

0

I believe you should add not path to file but path to folder that contains the jar.

Stan
  • 1,410
  • 10
  • 14
  • Sorry I wasn't clear in my original post - I have tried that also. I have edited my original post. – Laura Jun 08 '16 at 12:26
  • Did you try to specify classpath for 'java' command like "javac -cp libsbmlj.jar ToyGenInput" ? – Stan Jun 08 '16 at 12:31
  • This did seem to overcome the classpath problem (thanks!) but threw a new error: "ToyGenInput.java:13: error: cannot find symbol." Oddly it seems to be unable to recognise "s"? – Laura Jun 08 '16 at 13:57
  • It's difficult to say something since you didn't post any code – Stan Jun 08 '16 at 14:02
  • Hi Stan, I have added the code for ToyGenInput to the bottom of my question. It is the first "S" of both "SBML2SPA" terms that is causing the error – Laura Jun 08 '16 at 14:09
  • I suppose you didn't compile second file. If so try to compile it and also add to classpath – Stan Jun 08 '16 at 14:16
  • I have tried this and am still getting the same error (cannot find symbol) – Laura Jun 08 '16 at 14:43
  • Did you import SBML2SPA in ToyGenInput class? – Stan Jun 08 '16 at 14:54
  • Sorry Stan, could you tell me how to do that please? I'm a java newbie! I've had a look at some related questions but they seem to imply that having the 2 files in the same directory is enough for java? – Laura Jun 08 '16 at 15:19