Method and apparatus for classpath optimization in a Java runtime environment
Abstract
A computer implemented method, data processing system, and computer usable program are provided by the aspects of the present invention. Aspects of the present invention identify required classes of a software program in the import statements in the source code. Next, the aspects of the present invention identify an element in a classpath environment variable that contain only the required classes and generate a new classpath environment variable with the identified element. Aspects of the present invention then store the new classpath environment variable in a classpath file that is specific to the software program for subsequent invocation.
Claims
exact text as granted — not AI-modified1 . A computer implemented method for classpath optimization in a platform independent runtime environment, the computer implemented method comprising:
identifying a required class in an import statement in source code for a software program, wherein the required class is required by the software program; identifying an element containing the required class in a classpath environment variable to form an identified element, wherein the element includes at least one of a directory and an archive file; and generating a new classpath environment variable using the identified element.
2 . The computer implemented method of claim 1 , further comprising:
storing the new classpath environment variable in a classpath file, wherein the classpath file has a name of the software program and a classpath extension; responsive to user invoking the software program, determining if a classpath file with a name of the software program and a .classpath extension is present; and if the classpath file with a name of the software program and a .classpath extension is present, invoking the software program using the classpath file.
3 . The computer implemented method of claim 2 , wherein the invoking step comprises:
setting a runtime environment of the software program to the new classpath environment variable; and loading at least one class that is required by the software program using the new classpath environment variable.
4 . The computer implemented method of claim 1 , wherein the second identifying step comprises:
determining if a directory listed in the classpath environment variable contains the required class; if the directory contains the class, including the directory in the new classpath environment variable; and if the directory does not contain the required class, removing the directory from the new classpath environment variable.
5 . The computer implemented method of claim 4 , wherein the second identifying further comprises:
determining if an archive file listed in the classpath environment variable contains the required class; if the archive file contains the required class, including the archive file in the new classpath environment variable; and if the archive file does not contain the required class, removing the archive file from the new classpath environment variable.
6 . The computer implemented method of claim 5 , wherein the determining step comprises:
listing contents of the archive file using a java-tvf command; and examining contents of the archive file to determine if the archive file contains the required class.
7 . The computer implemented method of claim 1 , further comprising:
reordering directories and archive files in the classpath environment variable starting from directories and archive files with a largest number of classes to directories and archive files with a least number of classes.
8 . The computer implemented method of claim 2 , wherein the classpath file is specific to the software program.
9 . The computer implemented method of claim 1 , wherein the first identifying, second identifying, and the generating steps are performed once prior to an execution of the software program.
10 . A data processing system for classpath optimization in a platform independent runtime environment, the data processing system comprising:
a bus, a storage device, wherein the storage device contains computer usable code; a communications unit connected to the bus; and a processing unit connected to the bus, wherein the processing unit executes the computer usable code to identify a required class in an import statement in source code for a software program, wherein the required class is required by the software program; identify an element containing the required class in a classpath environment variable to form an identified element, wherein the element includes at least one of a directory and an archive file; and generate a new classpath environment variable using the identified element.
11 . The data processing system of claim 10 , wherein the processing unit further executes the computer usable program code to store the new classpath environment variable in a classpath file, wherein the classpath file has a name of the software program and a classpath extension and is specific to the software program; determine if a classpath file with a name of the software program and a .classpath extension is present responsive to user invoking the software program; and invoke the software program using the classpath file if the classpath file with a name of the software program and a .classpath extension is present.
12 . The data processing system of claim 10 , wherein the processing unit, in executing the computer usable program code to identify an element containing the required class in a classpath environment variable to form an identified element, executes the computer usable program code to determine if a directory listed in the classpath environment variable contains the required class; include the directory in the new classpath environment variable if the directory contains the class; and remove the directory from the new classpath environment variable if the directory does not contain the required class.
13 . The data processing system of claim 12 , wherein the processing unit, in executing the computer usable program code to identify an element containing the required class in a classpath environment variable to form an identified element, further executes the computer usable program code to determine if an archive file listed in the classpath environment variable contains the required class; include the archive file in the new classpath environment variable if the archive file contains the required class; and remove the archive file from the new classpath environment variable if the archive file does not contain the required class.
14 . The data processing system of claim 10 , wherein the processing unit further executes the computer usable program code to reorder directories and archive files in the classpath environment variable starting from directories and archive files with a largest number of classes to directories and archive files with a least number of classes.
15 . The data processing system of claim 10 , wherein the computer usable program code is executed by the processing unit once prior to an execution of the software program by the processing unit.
16 . A computer program product comprising:
a computer usable medium having computer usable program code for classpath optimization in a platform independent runtime environment, said computer program product including: computer usable program code for identifying a required class in an import statement in source code for a software program, wherein the required class is required by the software program; computer usable program code for identifying an element containing the required class in a classpath environment variable to form an identified element, wherein the element includes at least one of a directory and an archive file; and computer usable program code for generating a new classpath environment variable using the identified element.
17 . The computer program product of claim 16 , further comprising:
computer usable program code for storing the new classpath environment variable in a classpath file, wherein the classpath file has a name of the software program and a classpath extension; computer usable program code for responsive to user invoking the software program, determining if a classpath file with a name of the software program and a .classpath extension is present; and computer usable program code for invoking the software program using the classpath file if the classpath file with a name of the software program and a .classpath extension is present.
18 . The computer program product of claim 16 , wherein the computer usable program code for identifying an element containing the required class in the classpath environment variable to form an identified element, comprises:
computer usable program code for determining if a directory listed in the classpath environment variable contains the required class; computer usable program code for including the directory in the new classpath environment variable if the directory contains the class; and computer usable program code for removing the directory from the new classpath environment variable if the directory does not contain the required class.
19 . The computer program product of claim 18 , wherein the computer usable program code for identifying an element containing the required class in the classpath environment variable to form an identified element, further comprises:
computer usable program code for determining if an archive file listed in the classpath environment variable contains the required class; computer usable program code for including the archive file in the new classpath environment variable if the archive file contains the required class; and computer usable program code for removing the archive file from the new classpath environment variable if the archive file does not contain the required class.
20 . The computer implemented method of claim 1 , wherein the computer program product further comprising:
computer usable program code for reordering directories and archive files in the classpath environment variable starting from directories and archive files with a largest number of classes to directories and archive files with a least number of classes.Join the waitlist — get patent alerts
Track US2007061794A1 — get alerts on status changes and closely related new filings.
We store only your email — no account needed. See our privacy policy.