aspose file tools*
The moose likes Java in General and the fly likes SDKs Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "SDKs" Watch "SDKs" New topic
Author

SDKs

Karen Baog
Ranch Hand

Joined: Mar 02, 2005
Posts: 120
Java Gurus:

I have an SDK that support many languages, including Java. How do I "include" this in my Java program so I can use the available functions?


amerzil co-ed student<br />"Praise be the Code"
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

Presumably it would tell you in the documentation, but...

Part of this SDK would have to be a .jar file containing the Java classes (or, less likely, a single .class file or a directory full of class files, or a .zip file). All you have to do is include these on your class path when you compile and run your code. So if you're writing "MyApp", and the SDK comes with thesdk.jar, then you'd say

javac -cp .;c:\wherever\thesdk.jar MyApp.java
java -cp .;c:\wherever\thesdk.jar MyApp


[Jess in Action][AskingGoodQuestions]
Karen Baog
Ranch Hand

Joined: Mar 02, 2005
Posts: 120
So, I don't need to have some import statement. And, say, this SDK has some function called
int myFunc(int x)

? In my java code, does that mean I could write something like

int a = myFunc(2);

But I would expect an IDE would flag an error prior to compiling as this is not defined.

I'm using JBuilderX for my development. Is there a way (or possible) I could "include" this SDK in my JBuilderX directory structure?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42635
    
  65
No, your code would need to import the API classes.

As to the IDE questions, most IDEs allow you to add jar files to a project class path, but a user would need to do that - there's no way to do this automatically (unless you advise your users to install the jar file in a location where Java finds it automatically, like the endorsed libs directory).

Or you could include a sample project of your IDE that already has everything set up. Of course, to do that for each IDE is a bit of work.


Ping & DNS - my free Android networking tools app
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

Originally posted by Karen Baog:
So, I don't need to have some import statement.?


Yes, of course -- the 3rd-party API classes are no different in this respect than any of the Java API classes. If you use a class, you have to import it -- with the sole exceptions of java.lang classes, and classes in the same package as the one you're writing, of course.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: SDKs