2

I have installed Netbeans 6.9 just by one click thru Ubuntu Software Center. It didn't ask me for JDK installation folder during installation.

It works.

I want to check CLASSPATH variable just for learning purpose. But for the command echo $CLASSPATH.

It only gives a newline output.


I have checked for JDK directory in /usr/local directory. But I can't find JDK directory.
My questions are:

Where is the class files of API located in file system? System is a class in package "java.lang". Then the System class file must be in the path of /some/where/java/lang/System.class .
I want the path where the "java/lang/System.class" file resides.
Where is the packages physically located in file system?
Here the package means java package such as "java.lang" or "java.io" (I want just to know for learning purpose)

2 Answers 2

3

Open Alternatives Configurator:

Opening the Alternatives Configurator

Select java in the navigation sidebar:

Alternatives Configurator showing configured java alternatives

This will show you which java runtime environments / SDKs are installed, which one is currently active and where to find them, all in one go. The respective package names are similar (e.g. search Synaptic or Software Center for openjdk or java6).

4
  • Thank You! I found the directory.But I can't find java class files there. I hava used find /usr/lib/jvm -name *.class.But it didn't list any class files. Jun 24, 2011 at 12:24
  • Did you check the .jar files in your JRE's/JDK's directories? I doubt there would be any .class files outside of jar archives ...
    – nem75
    Jun 24, 2011 at 12:42
  • Hey nem75 ! I have found the class files (such as java.lang.System class) in a jar file namely rt.java in the path /usr/lib/jvm/java-1.5.0-gcj-4.4/jre/lib.But what could I do if I want to run java programs(belong to my own package) from command line ? I can't set class path variable. I think there is no classpath variable. I have tried echo $CLASSPATH.But it outputs a newline only.I can compile anyway.can't run if package keyword is used in program.It gives java.lang.NoClassDefFoundError. Jun 28, 2011 at 14:16
  • I'm by no means a Java specialist. You could try asking those new questions on stackoverflow.com, the StackExchange site for programmers.
    – nem75
    Jul 8, 2011 at 8:45
3

1). Inside the JDK installed path goto jre/lib, For instance in Linux the path maybe :- /usr/lib/jvm/java-7-openjdk-amd64/jre/lib

2). Copy the rt.jar in any temporary folder and only then extract it.

3). After extracting, You will then find the available built-in packages and classes inside these packages.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .