How to make use of Java's Graph Class? - java

So this is definitely a simple problem most likely with a simple fix but I just cannot figure out the issue here.
I am trying to make use of Java's Graph class:
http://docs.oracle.com/cd/E12839_01/apirefs.1111/e13403/javax/ide/util/Graph.html
however, I am unable to import javax.ide. There are many other packages/methods beginning with javax. that I am able to import as displayed in eclipse but javax.ide is not one of them:
I am, however, able to import java.util.AbstractCollection but my program still cannot resolve Graph to a type when I do this.
My guess is that the class is simply not in the library, I have tried updating my JDK but it doesn't seem to have changed anything. I apologize for my ignorance here, any help is much appreciated.

javax.ide.util is not part of the standard JDK. The link in the question takes you to an Oracle Fusion Middleware API subsection, which includes IDE API (JSR-198). You need to install additional libraries (probably Oracle Fusion Middleware) to get this package, but that would be an overkill to just get a graph library. It's better to evaluate your requirement and see what graph library suits your needs.

Related

Starting up an Intel SGX Enclave from a Java application

Good evening, and thanks to everyone in advance.
I am currently working on My MsC Thesis, and for the proposed solution so far, I am to use an existing Java application (BFT-SMART, built with gradle version 7.3.3) and add it a layer of confidentiality using Intel SGX, with the objective of each replica containing its own Intel SGX enclave.
My problem however, is not being able to start an enclave from a Java application other than a given example.
The given example was all I found, and after some changes to its make File, I was able to successfully execute this simple Java application in Simulation Mode.
https://github.com/lishen-nt/sgx-language-adapter/
However, how do I adapt this to something different? The given code:
static {
System.loadLibrary("Sgx");
}
/* Initialize the enclave */
public native int jni_initialize_enclave();
Seems to only work with this given example, not working with other tests that I have personally been trying, with the project being unable to find said library. Is there a way to add Make File statements to a gradle build in order to link Intel SGX Libraries to the project?
Before considering adding Intel SGX to the aforementioned project, I was trying to build my own sample project to base myself off of, any tips on this?
I do apologize for the extremely ambiguous and open-ended question, I am just at a complete loss of where to begin looking for options or examples I could base myself off of.
Thanks for everyone's help!
Rather than trying this old alternative (updated 4 years ago), I would try something newer, such as Scone or SGX-LKL. I think it would be easier to get some help and get success with your project.

Providing credentials to com.amazonaws.regions.Region.createClient() in AWS Java SDK 1.4.0

Amazon released version 1.4.0 of their Java SDK for AWS today, with the very welcome addition com.amazonaws.regions.Region, which describes the available regions and their services.
This class also provides the createClient() factory method for all client classes (subclassing com.amazonaws.AmazonWebServiceClient).
I don't understand how I can pass a custom AWSCredentialProvider to this method, as the second expected argument is a org.apache.http.client.CredentialsProvider.
I don't even understand how the method can work, because it uses Java reflection to try to find a constructor for the client classes with a org.apache.http.client.CredentialsProvider second argument, which does not exist.
It looks to me like this is a mistake in the code of the SDK, which has only be tested with the DefaultAWSCredentialsProviderChain.
Am I using this class incorrectly, or can I expect this mistake to be fixed soon ?
By the way, the lastest Javadoc does not include the com.amazonaws.regions package yet.
glad to hear you're excited about the new Regions code. It should make working with services in different AWS regions a little easier.
You are correct that the import statement in Region.java is importing the wrong CredentialsProvider. We'll get that fixed ASAP and released in the next version of the AWS SDK for Java.
I'm pushing out a new build of the Javadoc to our site that will include the com.amazonaws.regions namespace. Look for that to be out later this afternoon.
Thanks for reporting this problem! Hope you enjoy the new regions code. Let us know if you have any other feedback, suggestions or issues. We always love hearing from customers.

Where to find Java API Class diagrams?

Is there a site where we can find JAVA API class diagrams.
It helps to be able to see the class hierarchy (example Exception class hierarchy) in a visual manner.
Thanks.
This might not be as visual as you like, but the hierarchy can be seen in the official Java docs.
If your are asking for class hierarchy in general, found this one on Javase docs
There's nothing pre-built that I know of. If you're using an IDE (Eclipse, NetBeans, Intelli-J, etc.) it almost certainly has a built-in class hierarchy browser.
That said, the online JavaDocs do have a text-based class hierarchy for every single class. As per your example, here's what it shows for Exception:
http://docs.oracle.com/javase/7/docs/api/overview-tree.html though it is not uml,but i think it is clear
althoug there is not api uml,we can look api tree
i was looking for it too, i found this germany website click here.
That site represents all class diagrams and also provided you 223 pdf files with those diagrams.
The problem is the java version (java 1.4) but it still very helpful to me.
I have recently started adding such Class diagrams along with the class lists based on search criteria on my blog. Here are few samples -
http://www.buggybread.com/2015/09/java-class-diagram-collections-classes.html
http://www.buggybread.com/2015/10/java-javaio-stream-classes.html
http://www.buggybread.com/2015/10/java-se-list-of-algorithm-classes-and.html
http://www.buggybread.com/2015/10/java-se-javalang-string-classes.html
http://www.buggybread.com/2015/10/class-diagram-java-se-javautil-map_2.html
I haven't added lot of such material for Java SE and it's still not linked and indexed properly. Still you can search either on website or on google by adding the site name to your search. Thanks.

Porting blackberry application code in to Android platform

I have an Blackberry library written using JAVA as well Blackberry(RIM) specific API's. I would like to port the same library in to Android platform without making any code changes and make it run.
Here i am looking for the best way to achieve it
Any cross compiler/cross framework is available for making my Blackberry run on Android platform.Thinking this would make my job easy ;)
Please share your inputs on this.
Thanks in advance.
You can't do that. AFAIK, Blackberry uses J2ME technologies(can be wrong here). Android system is built in absolutely other principles. You have got to learn android in order to understand how to build GUI, how to process with background tasks and where you store your data. Sorry.
Start with application fundamentals.
If porting was that easy, a lot of developer would be out of work.
You will not have to rewrite the whole application, but surely there must be quite a few changes done. If you have a clean design, you might be able to reuse a lot of code as it is. Otherwise it will get more complicated. For the RIM API, it might be a good idea to write interface-classes first ("RIMXyz implements IntrfXyz"), that have all the function-call that you use of the RIM-API. Then you can write the Android API classes using "AndrXyz implements IntrfXyz". Put the RIM-dependend stuff in a separate external lib, and do the same with the android-dependent stuff. Then you can have a RIM-prj and an Android-prj, each only linking to the dependent classes and the reusable classes. That way you could structure you porting project quite nicely.
Also the "top" end of the application surely has to change, because you have to use the "activity"-class in Android to get anything running. Those are the two aspects I see.
I hope this is understandable, a bit hard to put it in a few words...
I have started a cross-platform project for Android/Java applet, and this is how I've done it. It works. ;-)
You cannot do this without some code rewrite. If you can tell us more about the classes in the RIM API that you are using, you might get some specific answers as to what classes from the Android API to use.
You should find similar functions in android api to replace RIM API invocations and refactor your code using for example Abstract Factory design pattern. (http://sourcemaking.com/design_patterns/abstract_factory)

How to understand Open Source projects/libraries?

There are few open source projects/APIs/libraries that we use in our project (Spring, Struts, iBatis etc.) and I want to understand their design and how they work internally.
What is the best way to understand these projects? Note that I am already using these libraries in my project. And I know the input-output interaction/configurations for these libraries. What I don't understand is how these APIs/libraries work internally.
The problems I face is:
Finding the entry class of the library. Is there any way I can know the entry class for the library - something which is kicking the whole API?
Tools/Plugins to use in Eclipse to get an overview of the design of the library. Going through each and every class of the library, can be a very daunting task. Is there any tool you would like to recommend which can generate the class diagrams of the API in Eclipse.
Thanks in advance!!
UPDATE: I need some inputs on eclipse plugins which can help me in getting an overview/class diagram of the library
I always use the same strategy for this: I never try to "understand" the code base as a whole, and I usually try to follow the request flow. I read enough of the documentation to determine what is necessary to use the application, and I read that code (Keep all source code loaded in your IDE).
For example, in struts you'll be installing a servlet filter in web.xml. Start reading the filter and follow the path a single request takes through your stack.
Likewise for spring, there are two main entry points, the filter and "getBean", both of which are mentioned real early in the documentation. Read those two.
For both of these cases you'll find one or two classes that represent the "core" of the framework real quickly. Read those really well and let actual use cases & needs drive your further exploration.
Approaching "understanding" of an open source library (or any other code base for that matter) by trying to find all the pieces is usually not a very good way of approaching these things, it will usually just lead nowhere because a lot of these things contain too much code. When following the request flow I find making diagrams can also be quite distracting, it tends to draw attention/focus away from understanding (and since my understanding increases rapidly most of them are out-of-date even before they reach the printer).
Nice question!!!, what I've done, specially in the case of Spring, apart from consulting the Documentation and their API's is to attach the sources of the project to my project on Eclipse, that way I'm able to navigate through the source code, not just the API. Its been quite helpful specially in the case of the Spring-Security project, there were some concepts that I just couldn't understand until I inspected the source code.
That's one of the advantages of using Open Source libraries.
Regards.
Tools like Structure101 (http://www.headwaysoftware.com/products/structure101/index.php), and Lattix (http://www.lattix.com/) let you analyze code and produce architecture diagrams / dependency matrices.
This is not exactly class diagram - the main focus is on layering. So the entry point is usually the topmost layer.
But then again, as I specified above, you will notice that some libs are just a mess, and these tools will not be helpful enough.
See the S101 online demo: http://www.structure101.com/java/
This for example is the Sonar project architecture: http://www.structure101.com/java/tracker/sonar/1.11.1/arch.html
Your best bet for those three would be to consult the official documentation (make sure you are looking at the version you are using) or to get a book on the technology.
Most APIs don't have a class with a main method; they're running in the webserver called by the server itself. Unless they're running as their own server, they won't have a main method.

Categories

Resources