2014-05-22 121 views
1

我知道有一个ImageJ插件处理NIfTI-1文件(http://rsb.info.nih.gov/ij/plugins/nifti.html)。知道什么方法在.jar文件

但是该页面上的所有说明都是使用ImageJ作为独立程序,但是我正在使用它的API。我怎样才能知道这个jar文件没有它的源文件有什么方法可用?

我也找不到源代码。

对于ImageJ的(如DICOM)支持的档案是很容易的:

public class ImageJTest { 
    public static void main(){ 
         String path = "res/vaca.dcm"; 
      FileInputStream fis; 
      ImageView image; 
      try { 
       fis = new FileInputStream(path); 
       DICOM d = new DICOM(fis); 
       d.run(path); 
       // Stretches the histogram because the pictures were being 
       // displayed too dark. 
       (new ij.plugin.ContrastEnhancer()).stretchHistogram(d, 0.1); 
       Image picture = SwingFXUtils.toFXImage(d.getBufferedImage(), 
         null); 
       // Makes the size standard for thumbnails 
       image = new ImageView(picture); 
      } catch (FileNotFoundException e) { 
       e.printStackTrace(); 
      } 
    } 
} 

我如何可以加载ImageJ中的NIfTI-1文件?

回答

3

一旦拥有了嵌入jar文件中的类文件(就像@Alvin Thompson指出的那样,这些文件只是一个不同名称的zip文件),您可以使用反射API来挖掘类文件以获取他们的方法。样本如下一类,从here那儿剽窃:

Method[] methods = thisClass.getClass().getMethods(); // thisClass is an instance of the class you're working with 

for(Method method : methods){ 
    System.out.println("method = " + method.getName()); 
} 
2

JAR文件只是看中的ZIP文件。您可以将该文件重命名为foo.zip,然后使用任何解压缩实用程序来扩展其内容。你应该至少能够看到类文件是什么,并且javadoc可能与它捆绑在一起(现在不太可能,但可能)。但是,如果您只想知道可用的方法,最好的方法是将JAR添加到NetBeans,Eclipse或IntelliJ中项目的类路径中,并使用它们的代码完成功能找出API方法和类。

0

你可以做的罐子甚至反编译,看到是使用反编译每个类后面的代码。 我发现的不错的一个:Java反编译器 JD-GUI主页:http://java.decompiler.free.fr

它确实很好,它的工作。至少在我的任务中。

+0

Erreur 403 - Refuter de traitement de larequête(Interdit - Forbidden) – Mansueli

+0

你也可以从这里得到它。 http://www.softpedia.com/get/Programming/Debuggers-Decompilers-Dissasemblers/JD-GUI.shtml – simion

相关问题