aspose file tools*
The moose likes Tomcat and the fly likes Why does Application Server need to host APIs ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Why does Application Server need to host APIs ?" Watch "Why does Application Server need to host APIs ?" New topic
Author

Why does Application Server need to host APIs ?

jignesh soni
Ranch Hand

Joined: Dec 10, 2007
Posts: 150
When a source code is written in java, APIs are used at that time by importing the package. Once source code is compiled and byte code is created, thats the one installed on servers. So everything needed now is the JRE to execute this byte code, whenever this code is invoked. So even if there is no API installed on application server, as long as JRE is there, this code will be executed. IS it correct ? So where is the need of APIs on application server ?

thanks
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30537
    
150

Jignesh,
I'm not sure what you mean by an API. If you mean a jar containing other classes, it is still needed as your code just links to those jars. If you mean the source code that you just compiled, you don't need it since you have the .class files.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61218
    
  66

Despite it's name, importing does not include a package's or class' code anywhere. It simply imports the definitions that are referenced in the code in the java file.

The .jar file containing the referenced code needs to be in the classpath when the code is executed.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
jignesh soni
Ranch Hand

Joined: Dec 10, 2007
Posts: 150
A source code is written using package imported in the code on the desktop. When this code is compiled, doe the compiler just check the availability of package on the desktop and compile the code or does it actually import the package at compile time ? If package is imported in the code and byte code is created, does the application server need only JRE or does it still need all the packages imported in the source code ?
If packages are not imported in the code at compile time, then all the packages will be required o the server in order to import tyhem at runtime.
My confusion is at what point of time , is the package imported in the source code ? Do these packages need to be on both the machines where source code is created and where byte code is deployed ?

In case of servlets, does the APIs imported in the code need to be on application server too ? Or does the bytecode have all the required APIs imported in it when source code is compiled ?

Please excuse the terminology used. As I am myself not clear and trying to get the whole idea how application server works and where these APIs need to be.

Thanks
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61218
    
  66

My reply already answered your question.
jignesh soni
Ranch Hand

Joined: Dec 10, 2007
Posts: 150
Still one thing is not clear.

1) Are these definitions or methods used from the imported package or class, are they used in the source code at compile time ? If no, then do these packages need to be available on the machine where the source code is created and compiled ?

2) If these methods in the source code from imported package are used at the runtime of bytecode, where bytecode is deployed (mostly application server)then these imported packages and APIs used in the code should be available on the application server.

So are these packages need to be available on both the machines where source code is created and where byte code is run ?

If possible, please answer questions point wise.

thanks
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61218
    
  66

The classes need to be available while compiling, and the classes need to be available at run-time.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Why does Application Server need to host APIs ?