Equivalent of File.separator in Javascript

How do I access the equivalent of [inlinecode]File.separator[/inlinecode] in a Javascript? It does not seem to be an attribute in http://javadoc.imagej.net/Java6/index.html?java/io/File.html. I was able to do

importPackage(Packages.ij.File);

But I’ve also been recommended to go directly to Java classes. What is the best approach?

There is no Java package called ij.File. Maybe you want:

importPackage(Packages.java.io);

?

It seemed to work…

I’m confused about when to import ImageJ packages/classes, and when to appeal directly to the Java classes. Also, how to find the Java classes I can access through ImageJ.

Are there rules of thumb I can follow?

Rule of thumb:

  • Use ImageJ classes when you are doing image-ish things—in particular, displaying or processing images.
  • Use Java classes for more general operations such as file I/O or string manipulation.

You can always ask on the forum here if there is a specific thing you cannot figure out how to do.

1 Like

This unfortunately isn’t the simplest of questions to answer. But everything that’s available should be listed in the Javadoc.

Assuming an unmodified Fiji installation with no update sites enabled, you should be able to access anything from these components, at a minimum:

  • ImageJ
  • ImgLib2
  • SCIFIO
  • SciJava
  • Fiji
  • ImageJ1
  • Bio-Formats
  • Java 6/7/8 (based on which version of Java is used to start ImageJ)

For example, looking through the Java 6 javadoc we eventually find the specification for File that would have helped in your original question.

1 Like

Thanks! That will be a good reference.

Thanks. Good rules to work with. I just want to get to be more self-sufficient.

1 Like