Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

SDKs

 
Karen Baog
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24211
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Karen Baog
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24211
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic