Java compiler contradicts Java book

NOW this is a big surprise...One of the Java book says "If a static member of the class, singleton in the ex below, is PUBLIC, the client (HelloUser in this case) can still access the static member even if the client is not in the same package" . I tried it but got the following error - singleton can't be accessed outside the package ? Any clues ?
import learn.*;
public class HelloUser {
    public static void main(String args[])
     Object obj[] = {new Integer(11), new Character('A')};
     Hello.print(obj);
     singleton.GetSingleton().print();
package learn;
class singleton {
    private static int mX;
    private singleton(int x) {mX = x;}
    private static singleton sSingle = new singleton(10);;
    public static singleton GetSingleton() {
     print();
     return sSingle;
    public static void print()
     System.out.println("Val: " + mX);
}

No, the book is not wrong just not quite complete. It should have stated that other classes in the same package have access ...OK, let's complete the original statement using your suggestion :
An object of a class with package access can be created by any class inside the package but not outside the package. However, if a static member of that class is public, the client programmer can still access that static member from withn the same package even though they can't create an object of that class.
Does this make any sense? No.

Similar Messages

  • What Java compiler for Java Card development ?

    What Java compiler and options should be used for Java Card development with the goal of generating correct, and (secondarily) small or/and fast code after conversion to Java Card bytecode using converter ?
    In particular
    - Is use of JDK 7 approved by Oracle for Java Card development? That would solve security problems associated with (the web components of the JRE of) some earlier JDK, including the latest JDK6. The JCDK 3.0.4 release notes states "+the commercial version of Java Development Kit (JDK software) version 6 Update 10 (JDK 6 Update 10) or later is required+, but that does not answer that question.
    - Anyone had _bad_ experience (like incorrect or disastrous code) with the Java compiler bundled with Eclipse ? I have seen at least one case where org.eclipse.jdt.core_3.7.3.v20120119-1537.jar produced slightly more compact code than javac.
    - Anyone had _bad_ experience with javac in jdk1.3 ? In an applet involving a "finally" clause, I've seen it generating more compact code than later javac (which in my test triplicated the code for the finally clause).

    What Java compiler and options should be used for Java Card development with the goal of generating correct, and (secondarily) small or/and fast code after conversion to Java Card bytecode using converter ?-target -source may be required to generate compatible byte code. Depending on the CAP file converter being used debug information may also help. Remember that Java Card is a subset of the Java language (also there are short opcodes that Java doesn't have etc) so a lot of the work for optimisation is done by the converter or the JCRE. You can look at the JCA code generated to determine what works best for your applets. There are also some ways of stripping out dead code etc from JCA files (return statements after a throw etc) to reduce your code size. Most of the speed optimisations come from your code (avoiding context switches and unnecessary security/access checks).
    The compactness of your Java Card binary may not be directly related to the size of your compiled Java code. It can depend on the converter you use and any optimisaitons the JCRE might try to do when the code is loaded.
    - Is use of JDK 7 approved by Oracle for Java Card development? That would solve security problems associated with (the web components of the JRE of) some earlier JDK, including the latest JDK6. Java Card does not use any of the libraries from the JDK/JRE. All of the libraries are provided by the JCRE on the smartcard.
    The JCDK 3.0.4 release notes states "+the commercial version of Java Development Kit (JDK software) version 6 Update 10 (JDK 6 Update 10) or later is required+, but that does not answer that question.Anything above JDK6u10 is supported. If you use Java 7 you may need to add a -source and -target flag when compiling.
    - Anyone had _bad_ experience (like incorrect or disastrous code) with the Java compiler bundled with Eclipse ? I have seen at least one case where org.eclipse.jdt.core_3.7.3.v20120119-1537.jar produced slightly more compact code than javac.We generally use the Eclipse compiler as we find that we get more deterministic builds. When CAP files are sent for security review it is helpful to have the reviewer able to generate a CAP file that matches the one you sent to confirm the binary is what you say it is.
    - Anyone had _bad_ experience with javac in jdk1.3 ? In an applet involving a "finally" clause, I've seen it generating more compact code than later javac (which in my test triplicated the code for the finally clause).We do not use anything less than Java 6 for compilation.
    - Shane

  • Java compiler validation

    I've developed a java compiler in java that will be used in a tool to teach java programming. I'd like to test the compiler with an independent set of programs.
    Anyone know of a free/inexpensive compiler validation suite of programs?
    Many thanks.
    Lindsey Ford

    Hey Keith,
    You may want to post this question on the jboss community forum. No idea what's going on here...
    Bob

  • Java Compilation

    Hi ,
    I want to know how the JAVAC and JAVA command works internally. And also the JVM and JDK architecture to understand the java compilation and execution process. Can anybody help me out .
    Thanks
    Raghav

    raghav1212 wrote:
    Hi ,
    I want to know how the JAVAC and JAVA command works internally. And also the JVM and JDK architecture to understand the java compilation and execution process. Can anybody help me out .Well time to study generic compiler theory then. Its a fun fun world of abstract syntax trees, lexical analysis, etc. etc. Your question is not Java programming related in any case and certainly not something to pose in a forum - perhaps you can find a good book on compiler theory. Its very complex material, I warn you.

  • 6 errors trying to compile TalkClientApplet.java

    Hello:
    Trying to compile TalkClientApplet.java at:
    http://java.sun.com/docs/books/tutorial/deployment/applet/ex5/TalkClientApplet.java
    on the jdk1.5.0_06, Windows XP, and I received the following errors:
    TalkClientApplet.java:94:incomparable types:boolean and <nulltype>
    if(receivedThread ==null){
    TalkClientApplet.java:99:incompatible types
    found:java.lang.Thread
    required:boolean
    receiveThread=new Thread(this);
    TalkClientApplet.java:100:boolean cannot be dereferenced
    receiveThread.start();
    TalkClientApplet.java:150:incompatible types
    found :<nulltype>
    required:boolean
    receiveThread=null;
    TalkClientApplet.java:186:incomparable types:boolean and <nulltype>
    if(receiveThread==null){
    TalkClientApplet.java:258:incomparable types:java.lang.Thread and
    boolean while (Thread.currentThread()==receiveThread){
    Thanks in advance for your help.

    Hello:
    I am following the code from:
    http://java.sun.com/docs/books/tutorial/deployment/applet/ex5/TalkClientApplet.java
    which was pointed to from:
    http://java.sun.com/docs/books/tutorial/deployment/applet/workaround.html
    This is the section:
    private void start(boolean onEDT) {       
    if (DEBUG) {
    System.out.println("In start() method.");
    if (receiveThread == null) {
    trysted = false;
    os = null;
    is = null;
    socket = null;
    receiveThread = new Thread(this);
    receiveThread.start();
    if (DEBUG) {
    System.out.println(" Just set everything to null and started thread.");
    enableGUI(onEDT);
    Thanks

  • Compiler in Java

    GentlePeople:
    I hoping for some suggestions as respects to reading material and learning sources.
    I need to write a compiler in Java. I have been told the dragonbook as the go to book. Is that the case for doing in Java as well. I need to learn:
    How to design a compiler
    How to implement a compiler in java.
    If you have any reading suggestion, books, articles, etc; I would really appreciate it. You guys are always tops on these forums.
    ~Brian

    You don't need to learn how to write a compiler in Java. You need to learn Java, and you need to learn how to write a compiler. Those two are completely independent of each other, and once you have learned each of them independently, you can combine them.

  • Help, payed $20 for java on cd and book but i cant get it to work

    someone please help me, im trying to learn java to do a project for my church but after i installed it and everything was as it should be, i cant figure out how to use it, i am so confused, i am used to using things like borlans java compiler but i cant get this version to work can someone please help me, im so stressed out.. and if you dont mind could u email ur responce to [email protected] i dont check the same pages over and over again verry often. thnks :-)

    Ben,
    this tutorial will open the door to java programming.
    Any Qs ask.
    http://java.sun.com/docs/books/tutorial/getStarted/cupojava/win32.html

  • How to run and compile a java servlet on Tomcat?

    Hi, I am very new to servlets in Tomact.
    I went to the java tutorial and from the address below I copy an example (SimpleServlet).I try to run and compile it in Tomcat, But I don't know how can I do that. I appreciate if somebody tell me the command line for compiling and running this example and the necassary steps. (My Tomcat is installed perfactly).
    http://java.sun.com/docs/books/tutorial/servlets/overview/simple.html
    Thankx

    Hello,
    I have the similar question.
    Instead of going thru sun's tutorial, I tried onjava's ("http://www.onjava.com/pub/a/onjava/2001/04/19/tomcat.html?page=1").
    I could see the jsp page, but when I tried to add a servlet, I got an error "Page not found". I followed exactly the same way they describe. The only thing I noticed was the resulting page on the tutorial had the URL of ".../servlet/...".
    Is this "servlet" directory something we are supposed to create our own? If so, under what directory? Or do we need to set up anything in order for the servlet to be referenced that way?
    Thanks in advance.

  • My class only compiles in Java 1.6 and not in Java 1.5

    Hi, my java class wont compile in java 1.5, it only compiles in Java 1.6. How can i compile the following?
    import java.util.*;
    public class ShoppingBasket
         Vector products;
         public ShoppingBasket() { products = new Vector(); }
         public void addProduct(Product product)
         boolean flag = false;
         for(Enumeration e = getProducts(); e.hasMoreElements();)
              { Product item = (Product)e.nextElement();
                   if(item.getId().equals(product.id))
                   {flag = true; item.quantity++; break; }
              if(!flag){ products.addElement(product);}
         public void deleteProduct(String str)
              for(Enumeration e=getProducts();
              e.hasMoreElements();)
              { Product item = (Product)e.nextElement();
                   if(item.getId().equals(str))
                   {products.removeElement(item); break; }
         public void emptyBasket(){products = new Vector();}
         public int getProductNumber(){ return products.size();}
         public Enumeration getProducts() { return products.elements(); }
         public double getTotal()
         Enumeration e = getProducts();
         double total; Product item;
         for(total=0.0D;e.hasMoreElements();     total+= item.getTotal())
         {item = (Product)e.nextElement(); }
         return total;
    }It should link with a class called Product which compiles fine... the errors i get are below:
    K:\jakarta-tomcat-5.0.18\webapps\ROOT\WEB-INF\classes\ShoppingBasket\ShoppingBas
    ket.java:6: cannot find symbol
    symbol  : class Product
    location: class ShoppingBasket
            public void addProduct(Product product)
                                   ^
    K:\jakarta-tomcat-5.0.18\webapps\ROOT\WEB-INF\classes\ShoppingBasket\ShoppingBas
    ket.java:10: cannot find symbol
    symbol  : class Product
    location: class ShoppingBasket
                    { Product item = (Product)e.nextElement();
                      ^
    K:\jakarta-tomcat-5.0.18\webapps\ROOT\WEB-INF\classes\ShoppingBasket\ShoppingBas
    ket.java:10: cannot find symbol
    symbol  : class Product
    location: class ShoppingBasket
                    { Product item = (Product)e.nextElement();
                                      ^
    K:\jakarta-tomcat-5.0.18\webapps\ROOT\WEB-INF\classes\ShoppingBasket\ShoppingBas
    ket.java:20: cannot find symbol
    symbol  : class Product
    location: class ShoppingBasket
                    { Product item = (Product)e.nextElement();
                      ^
    K:\jakarta-tomcat-5.0.18\webapps\ROOT\WEB-INF\classes\ShoppingBasket\ShoppingBas
    ket.java:20: cannot find symbol
    symbol  : class Product
    location: class ShoppingBasket
                    { Product item = (Product)e.nextElement();
                                      ^
    K:\jakarta-tomcat-5.0.18\webapps\ROOT\WEB-INF\classes\ShoppingBasket\ShoppingBas
    ket.java:35: cannot find symbol
    symbol  : class Product
    location: class ShoppingBasket
            double total; Product item;
                          ^
    K:\jakarta-tomcat-5.0.18\webapps\ROOT\WEB-INF\classes\ShoppingBasket\ShoppingBas
    ket.java:36: inconvertible types
    found   : <nulltype>
    required: double
            for(total=0.0D;e.hasMoreElements();     total+= item.getTotal())
                                                                         ^
    K:\jakarta-tomcat-5.0.18\webapps\ROOT\WEB-INF\classes\ShoppingBasket\ShoppingBas
    ket.java:37: cannot find symbol
    symbol  : class Product
    location: class ShoppingBasket
            {item = (Product)e.nextElement(); }
                     ^
    8 errors

    fahafiz wrote:
    ah, so should i put the classes into the folder which the classpath is assigned to?More likely you should assign your classpath to whatever folder your classes are in.
    Put your files where they make sense, and then fill in classpath accordingly:
    javac -classpath classpath MyFile.java(I think, it's been a while since I compiled from the command-line, see http://java.sun.com/j2se/1.4.2/docs/tooldocs/windows/javac.html)

  • Compiles in Java 5.0 but not 6.0

    I did my homework on my school computer (in eclipse) and compiled in in 6.0 and everything worked. Then I saved it to a usb drive
    and brought it home. I tried to run it on my computer (in eclipse) in 6.0 and it gave me this error:
    Exception in thread "main" java.lang.UnsupportedClassVersionError: Bad version number in .class file
         at java.lang.ClassLoader.defineClass1(Native Method)
         at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
         at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
         at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
         at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
         at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
         at java.security.AccessController.doPrivileged(Native Method)
         at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
         at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
         at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
         at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
         at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)when I tried to run it. The weird thing is, if I change eclipse's preferences to compile in 5.0 everything works fine. I just don't understand
    why it compiled in 6.0 at school but won't work on my home computer in 6.0? I'm worried that my teacher might grade the assignment in
    6.0 because if he does I'll get a 0 even though everything works 100% in 5.0.
    I was just wondering if anyone could shed some light on this for me. Thanks in advance!
    Here is my assignment (just giving this so you know what the program is suppose to do):
    http://www2.ics.hawaii.edu/~esb/2008spring.ics211/hw9.html
    It basically reads from a file and adds items in the file to a PriorityQueue using a heap as the data structure. It keeps track of levels
    traversed to re-establish the heap property. How long add/poll take in realTime. And when add/poll occurs in simulatedTime.
    Here's my program:
    import java.io.*;
    import java.util.*;
    public class KinseyAnthony9<T> {
         private static String name = "";
         private static long deadline;
         private static long duration;
         private static int time;
         private static int simulatedTime = 0;
         private static boolean add;
         public static void ProcessLine(Scanner line){
              if(line.next().equalsIgnoreCase("schedule")){
                   add = true;
                   if(line.hasNext()){
                        name = line.next();
                   if(line.hasNext()){
                        deadline = Long.parseLong(line.next());
                   if(line.hasNext()){
                        duration = Long.parseLong(line.next());
                   else {
                        System.out.print("There is a format error in the supplied file");
                        System.exit(1);
                   return;
              else {
                   add = false;
                   if(line.hasNext()){
                        time = Integer.parseInt(line.next());
                   else {
                        System.out.print("There is a format error in the supplied file");
                        System.exit(1);
         public static void main(String[] param) {
              Comparator<MyProc> procCompare = new ProcComparator();
              MyPQueue<MyProc> myQueue = new MyPQueue<MyProc>(procCompare);
    //          PriorityQueue<MyProc> myQueue = new PriorityQueue<MyProc>(1000, procCompare);
              if(param.length == 1) {
                   try {
                        File readMe = new File(param[0]);
                        Scanner readFile = new Scanner(readMe);
                        String line = "";
                        while(readFile.hasNextLine()) {
                             line = readFile.nextLine();
                             Scanner readLine = new Scanner(line);
                             ProcessLine(readLine);
                             if(add) {
                                  System.out.println(simulatedTime + ": adding " + name + " with deadline " + deadline + " and duration " + duration + ".");
                                  myQueue.add(new MyProc(name, deadline, duration));
                             else if(!add) {
                                  String procName = "";
                                  long procDeadline = 0;
                                  long procDuration = 0;
                                  while(simulatedTime != time) {
                                       Scanner procScan = null;
                                       int queueSize = myQueue.size();
                                       if(queueSize <= 0) {
                                            simulatedTime = time;
                                            break;
                                       if(queueSize > 0) {
                                            procScan = new Scanner(myQueue.peek().toString());
                                            procName = procScan.next();
                                            procDeadline = Long.parseLong(procScan.next());
                                            procDuration = Long.parseLong(procScan.next());
                                            System.out.println(simulatedTime + ": performing " + procName + " with deadline " + procDeadline + " and duration " + procDuration + ".");
                                            myQueue.poll();
                                            simulatedTime += procDuration;
                                            if(simulatedTime > time) {
                                                 System.out.println((simulatedTime-procDuration) + ": adding " + procName + " with deadline " + procDeadline + " and duration " + (simulatedTime-time) + ".");
                                                 myQueue.add(new MyProc(name, deadline, (simulatedTime-time)));
                                                 simulatedTime = time;
                                                 break;
                                            else if(simulatedTime <= time) {
                                                 if(procDeadline < simulatedTime) {
                                                      System.out.println(simulatedTime + ": done performing " + procName + " (late).");
                                                 else {
                                                      System.out.println(simulatedTime + ": done performing " + procName + ".");
                   //catch any exception that might occur
                   catch(Exception e){
                        System.out.println(e); //print out the error
                        System.exit(1); //exit
              //Check if more than one or less than one parameter is entered
              else {
                   //if so give an error
                   System.out.println("Error with parameter.");
                   System.exit(1); //exit
    class ProcComparator implements Comparator<MyProc>{
         public int compare(MyProc x, MyProc y){
              long result = x.getDeadline() - y.getDeadline();
              if(result < 0)
                   return -1;
              else if(result > 0)
                   return 1;
              else
                   return 0;
    class MyPQueue<T>{
         public MyHeap<T> theHeap;
         public MyPQueue(Comparator<T> comp) {
              theHeap = new MyHeap<T>(comp);
         public boolean add(T item){
              if(theHeap.add(item)) return true;
              else return false;
         public T peek(){
              return theHeap.peek();
         public int size(){
              return theHeap.numItems();
         public T poll(){
              T result = null;
              if(theHeap.numItems() == 0) return result;
              try{
                   result = theHeap.remove();
              catch(Exception e){
                   System.out.println(e);
                   System.exit(1);
              return result;
         public String toString(){
              return theHeap.toString();
    @SuppressWarnings("unchecked")
    class MyHeap<T>{
         private Comparator<T> heapComparator = null;
         private final int MAX_SIZE = 1000;
         private T heap[];
         private int rTraverseCount = 0;
         private int aTraverseCount = 0;
         public MyHeap(Comparator<T> comp){
              heapComparator = comp;
              heap = (T[])new Object[MAX_SIZE];
         public int numItems() {
              int numItems = 0;
              for(int i = 0; heap[i] != null; i++) {
                   numItems++;
              return numItems;
         public T peek() {
              if(numItems() == 0) return null;
              return heap[0];
         public boolean add(T item) {
              long start = System.nanoTime();
              long time;
              int numItems = numItems();
              if(numItems == 0) {
                   heap[numItems] = item;
                   System.out.println("--> " + aTraverseCount +" levels were traversed to re-heapify the tree.");
                  time = System.nanoTime() - start;
                   System.out.println("--> It took " + time + "ns to complete the add operation.");
                   return true;
              else if(numItems > 0) {
                   heap[numItems] = item;
                   siftUp(0, numItems);
                   if(aTraverseCount == 1)
                        System.out.println("--> " + aTraverseCount +" level was traversed to re-heapify the tree.");
                   else
                        System.out.println("--> " + aTraverseCount +" levels were traversed to re-heapify the tree.");
                   aTraverseCount = 0;
                   time = System.nanoTime() - start;
                   System.out.println("--> It took " + time + "ns to complete the add operation.");
                   return true;
              return false;
         public T remove() throws Exception{
              long start = System.nanoTime();
              long time;
              int numItems = numItems();
              T result = heap[0];
              if(numItems == 0){
                   throw new Exception("NoSuchElementException");
              if(numItems == 1){
                   heap[0] = null;
                   time = System.nanoTime() - start;
                   System.out.println("--> It took " + time + "ns to complete the remove operation.");
                   System.out.println("--> " + rTraverseCount +" levels were traversed to re-heapify the tree.");
                   return result;
              else {
                   heap[0] = heap[numItems - 1];
                   heap[numItems - 1] = null;
                   removalswap(0);
                   if(rTraverseCount-1 == 1)
                        System.out.println("--> " + (rTraverseCount-1) +" level was traversed to re-heapify the tree.");
                   else
                        System.out.println("--> " + (rTraverseCount-1) +" levels were traversed to re-heapify the tree.");
                   rTraverseCount = 0;
              time = System.nanoTime() - start;
              System.out.println("--> It took " + time + "ns to complete the remove operation.");
              return result;
         public void removalswap(int root) {
              rTraverseCount++;
              T valueHolder = heap[root];
              int left = (2*root) + 1;
              int right = (2*root) + 2;
              if(heap[right] != null && heap[left] != null){ //make sure left and right children aren't null
                   if(heapComparator.compare(heap[root],heap[left]) <= 0 &&  //if root is less than or equal
                      heapComparator.compare(heap[root],heap[right]) <= 0) return; //to its children return
                   if(heapComparator.compare(heap[root],heap[left]) > 0){ //if root is greater than left
                        if(heapComparator.compare(heap[left], heap[right]) > 0){ //compare left and right
                             heap[root] = heap[right]; //and swap with the smaller of the two
                             heap[right] = valueHolder;//in this case right is smaller so swap with right
                             removalswap(right);
                        else { //in this case left is smaller so swap with left
                             heap[root] = heap[left];
                             heap[left] = valueHolder;
                             removalswap(left);
                   else if(heapComparator.compare(heap[root],heap[right]) > 0){ //root can be greater than left
                             heap[root] = heap[right]; //but smaller than right. In this case just swap with the
                             heap[right] = valueHolder; //right child.
                             removalswap(right);               
              else if(heap[right] == null && heap[left] != null){ //the right child can be null while the left child
                   if(heapComparator.compare(heap[root],heap[left]) <= 0) return;//is not, but the left child will never
                   else { //be null if the right child isn't. If this is the case see if the root is greater than the
                        heap[root] = heap[left]; //left child and swap if so.
                        heap[left] = valueHolder;
                        removalswap(left);
         public void siftUp(int root, int end) {
              int child = end;
              int parent = (child-1)/2;
              while(child > root){
                   parent = (child-1)/2;
                   if(heapComparator.compare(heap[parent], heap[child]) > 0) {
                        swap(parent,child);
                        child = parent;
                   else{
                        return;
         public void swap(int parent, int child){
              aTraverseCount++;
              T holdValue = heap[parent];
              heap[parent] = heap[child];
              heap[child] = holdValue;
         public String toString(){
              int i = 0;
              String heapPrint = "";
              while(heap[i] != null){
                   heapPrint += heap;
                   i++;
              return heapPrint;
    class MyProc {
         private String name;
         private long deadline;
         private long duration;
         public MyProc(String n, long dl, long dur) {
              name = n;
              deadline = dl;
              duration = dur;
         //Acessors
         public String getName() {
              return name;
         public long getDeadline() {
              return deadline;
         public long getDuration() {
              return duration;
         //Mutators
         public void setName(String n) {
              name = n;
         public void setDeadline(long dl) {
              deadline = dl;
         public void setDuration(long dur) {
              duration = dur;
         public String toString(){
              return name + " " + deadline + " " + duration;
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    But if I run that in terminal I get this:
    anthony-computer:~ anthonyjk$ java -version
    java version "1.5.0_13"Yes - commandline/Terminal, that's what I meant.
    So long as the program doesn't use any 1.6-only features, then will it will compile OK both at school (using1.6) and at home (using 1.5). Eclipse can be told to produce .class files that are compatible with a particular runtime. In your case the school compiler was producing 1.6 class files that are no good when you take them home. Hence the need to recompile, telling Eclipse you want 1.5 compatible .class files.
    Or - as I mentioned - download and install the most recent JDK for use at home. There'll be less confusion that way

  • Run time java compiler

    Last year I researched oracle spatial technology and created prototype using oracle 9i, standalone oc4j. In order to start oc4j, i had to download java 1.4.2 from sun site. everything worked fine.
    Now I am expanding on the prototype on different machine but am using oracle 10g. I followed the same steps (installed 10g, oc4j, downloaded j2se 1.4.2 and installed). When I start oc4j by following command
    java -jar oc4j.jar, I get
    error message stating Error loading package at file:/E:/oracle_downloads/oc4j/j2ee/home/applications/admin_ejb.jar, javac.exe no
    t found under F:\oracle\product\10.1.0\db_1\jre\1.4.2, please use a valid jdk or
    specify the location of your java compiler in server.xml using the <java-compil
    er .../> tag.
    I am not sure how do I specify location of java compiler in server.xml file sysntactically. I do not not recall this step with oracle 9i.
    I edited server.xml and http-wev-site.xml as per instructions in my spatial class for mapviewer application but I need help on how to enter the location of java compiler file in server.xml file.
    Thank you

    You cannot use the JRE java to start oc4j. Must install a complete 1.4.2 J2SDK (not JRE) then use the java binary under its bin directory to start oc4j (not the one under jre/bin directory).
    lj

  • Error while compiling QuoteRenderer.java file

    Currently I am working on Quotes customizations. As part of customizations, I need to modify the seeded java file (i.e., $JAVA_TOP/oracle/apps/qot/util/QuoteRenderer.java)
    Since i have only class files, I have decompiled the class file using JAD and modified the code and placed in the same path and tried to compile. Then I am getting the below errors: [I am getting the same errors even if i placed the decompiled file without any modifications]. Can you help in resolving this issue.
    Errors:
    oracle/apps/qot/util/QuoteRenderer.java:16: package javax.servlet.jsp does not exist
    import javax.servlet.jsp.JspWriter;
    ^
    oracle/apps/qot/util/QuoteRenderer.java:17: package javax.servlet.jsp does not exist
    import javax.servlet.jsp.PageContext;
    ^
    oracle/apps/qot/util/QuoteRenderer.java:127: cannot find symbol
    symbol : class PageContext
    location: class oracle.apps.qot.util.QuoteRenderer
    public static void loadQuoteLines(HttpServletRequest httpservletrequest, HttpServletResponse httpservletresponse, PageContext pagecontext, int i)
    ^
    oracle/apps/qot/util/QuoteRenderer.java:664: cannot find symbol
    symbol : class PageContext
    location: class oracle.apps.qot.util.QuoteRenderer
    public static void loadQuoteLines(HttpServletRequest httpservletrequest, HttpServletResponse httpservletresponse, PageContext pagecontext, String s, String s1)
    ^
    oracle/apps/qot/util/QuoteRenderer.java:775: cannot find symbol
    symbol : class PageContext
    location: class oracle.apps.qot.util.QuoteRenderer
    public static void loadQuoteLines(HttpServletRequest httpservletrequest, HttpServletResponse httpservletresponse, PageContext pagecontext, String s)
    ^
    oracle/apps/qot/util/QuoteRenderer.java:838: cannot find symbol
    symbol : class PageContext
    location: class oracle.apps.qot.util.QuoteRenderer
    private static void partialLoadQuoteLines(HttpServletRequest httpservletrequest, HttpServletResponse httpservletresponse, PageContext pagecontext, int i)
    ^
    oracle/apps/qot/util/QuoteRenderer.java:916: cannot find symbol
    symbol : class PageContext
    location: class oracle.apps.qot.util.QuoteRenderer
    public static void loadExpandList(HttpServletRequest httpservletrequest, HttpServletResponse httpservletresponse, PageContext pagecontext)
    ^
    oracle/apps/qot/util/QuoteRenderer.java:975: cannot find symbol
    symbol : class PageContext
    location: class oracle.apps.qot.util.QuoteRenderer
    public static void renderQuoteLines(HttpServletRequest httpservletrequest, HttpServletResponse httpservletresponse, PageContext pagecontext, String s, String s1)
    ^
    oracle/apps/qot/util/QuoteRenderer.java:1652: cannot find symbol
    symbol : class PageContext
    location: class oracle.apps.qot.util.QuoteRenderer
    public static void renderQuoteLineSmry(HttpServletRequest httpservletrequest, HttpServletResponse httpservletresponse, PageContext pagecontext, String s)
    ^
    oracle/apps/qot/util/QuoteRenderer.java:386: reference to QuoteException is ambiguous, both method QuoteException(java.lang.String,java.lang.Object[]) in oracle.apps.qot.core.QuoteException and method QuoteException(java.lang.String,java.lang.String) in oracle.apps.qot.core.QuoteException match
    throw new QuoteException(s2, null);
    ^
    oracle/apps/qot/util/QuoteRenderer.java:982: cannot find symbol
    symbol : class JspWriter
    location: class oracle.apps.qot.util.QuoteRenderer
    JspWriter jspwriter = pagecontext.getOut();
    ^
    oracle/apps/qot/util/QuoteRenderer.java:1659: cannot find symbol
    symbol : class JspWriter
    location: class oracle.apps.qot.util.QuoteRenderer
    JspWriter jspwriter = pagecontext.getOut();
    ^
    Note: oracle/apps/qot/util/QuoteRenderer.java uses or overrides a deprecated API.
    Note: Recompile with -Xlint:deprecation for details.

    Hi,
    You need to add librabry for j2ee-1.4.jar in your classpath this can be found under JSP Runtime library in your jdevhome\jdevbin folder.
    ~Ankul

  • How to compile a java file which is in memory?

    how to compile a java file which is in memory?
    such as:
    String s="class MyClass {....}";
    how to compile the string?
    thx

    come on ...That was a perfectly valid solution.
    Do you know how to call the sun.* compiler? If not then search the forums for it. If that interface still exists (which it might not in newer versions) you then will create a string stream from your class and pass it to that.

  • How to run a java program without Java Compiler

    I have a small project and I want share it with my friends but my friend'pc have not
    Java compiler.
    for example, I writen a application like YM, then 2cp can sent,receive messege. My cumputer run as Server, and my frien PC run as client.
    How can my friend run it? or how to create an icon in dektop tu run a java program..??..
    (sorry about my English but U still understand what i mean (:-:)) )

    To run a program you don't need a Java compiler. Just the Java Runtime Engine. That can be downloaded from the Sun website and comes with an installer.
    You could then turn your application into an executable jar file and start it somehow like jar myYM.
    There is also software that packs a Java program into an executable file. I've never used that but one that comes to my mind is JexePack. It's for free if you can live with a copyright message popping up every time you start the program.
    http://www.duckware.com/jexepack/index.html

  • Problem in compiling this java need help

    package test;
    public class simpleTest{
         public simpleTest(){
              int a =0;
    import test.*;
    public class testPackage{
         public static void main(String [] args){
              simpleTest sT=new simpleTest();
              System.out.println("Package from Test A value = "+a);
    }error got when compile this codes.
    --------------------Configuration: <Default>--------------------
    C:\Notes\testPackage.java:4: cannot access simpleTest
    bad class file: C:\Notes\simpleTest.java
    file does not contain class simpleTest
    Please remove or make sure it appears in the correct subdirectory of the classpath.
    simpleTest sT=new simpleTest();
    ^
    1 error
    Process completed.

    package test;
    public class simpleTest{
    private int a;
         public simpleTest(int a){
              // int a =0;
    this.a = a;
    public int getA() {
    return a;
    =============== 2 diff files===================
    import test.*;
    public class testPackage{
         public static void main(String [] args){
              simpleTest sT=new simpleTest();
    System.out.println("Package from Test A value =
    = "+st.getA());
    }- Saishu can compile the java package?

Maybe you are looking for

  • Issue with CHECK_CHANGED_DATA  method of CL_GUI_ALV_GRID class

    HI, I want to check whether my grid has any changes or not, for that i am using the CHECK_CHANGED_DATA method of CL_GUI_ALV_GRID class, What i am doing is.... I am doing some changes in my grid data  and clicking on SAVE . This time  CHECK_CHANGED_DA

  • Edit in Photoshop will not use sRGB

    When I edit images from Lightroom in Photoshop (Ctrl+E), I can set up a colour space to use for the export. Setting it to Adobe RGB or ProPhoto leads to the expected result that Photoshop asks me whether to use the embedded profile or convert to my w

  • Modifying permissions crashes Finder

    I have found that using the "Get Info" window to modify permissions for files and folders in Finder often result in Finder crashing (and automatically restarting). This seems to be a problem specific to Leopard, as I had not noticed this prior to upg

  • How to print terms and cond of a PO in a fresh page in smartforms??

    hi All, My requirement is as follows... i need to print terms and conditions of a purchase order after the main window and the amount has been printed. the terms and conditions should be in a fresh page. i.e if the line items items and the amounts wi

  • Destroyed messages by mistake. how can I reload them ?

    I created a new gmail account. Loaded new messages. Deleted them and emptied garbage can. Messages are still on gmail but thunderbird do not reload them.