Get available java package functions / methods in C #

I want to know that you can get the classes, functions / methods available in the java package from C #. Suppose I have a java package containing a SampleClass. I want to test this package with C # so that I can get a SampleClass. I do not want to use this class in C #, in fact I just want to get the name of the available classes and functions.

Hope this is possible!

thanks

+2
source share
2 answers

Assuming you have JDK installed, you can use "jar -tf jarName.jar" to get a list of classes that you can parse.

To get additional information about a particular class, you can use the command line javap utility to print a list of all methods and fields. It is in a fairly easily distinguishable format. For instance:

javap -classpath . com.prosc.io.ZipCreator Compiled from "ZipCreator.java" public class com.prosc.io.ZipCreator extends java.lang.Object{ public com.prosc.io.ZipCreator(); public java.lang.Integer getLevel(); public void setLevel(java.lang.Integer); public void createZip(java.io.File, java.io.File) throws java.io.IOException; public void createZip(java.io.File, java.util.zip.ZipOutputStream) throws java.io.IOException; public void setMaximumZipSize(long); static {}; } 
+4
source

If you ask about Jar files. This is just a zip file.

You can map folders and files to these class names: "/java/lang/Object.class" β†’ "java.lang.Object".

In this post, you can read about listing the contents of a .zip folder in C #.

The advantage of this method is that you do not need to worry about the installed JDK, but if you are planning something complicated, for example. a list of methods that I would like to find for the solution suggested by @Jesse Barnum.

+1
source

All Articles