The Artima Developer Community
Sponsored Link

Java Answers Forum
how to do configuration to load java standard library?

5 replies on 1 page. Most recent reply: May 9, 2002 2:40 AM by Thomas SMETS

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 5 replies on 1 page
tech illin

Posts: 3
Nickname: illin
Registered: Apr, 2002

how to do configuration to load java standard library? Posted: Apr 23, 2002 9:02 PM
Reply to this message Reply
Advertisement
I composed a small program, which made use of Arrays class in java standard librabry.



import java.util.*;
....
boolean[] a1 = new boolean[size];
Arrays.fill(a1, true);
...



But an error turned out, like:

F:\myJava\c09\FillingArrays.java:21: cannot resolve symbol
symbol : method fill (boolean[],boolean)
location: class Arrays
Arrays.fill(a1, true);
^




How can I solve this problem?
now I am using win2000,
my classpath=.;f:\myJava\
my jdk path is c:\jdk1.3.1
should I add some configuration to connect to JDK library?


Thomas SMETS

Posts: 307
Nickname: tsmets
Registered: Apr, 2002

Re: how to do configuration to load java standard library? Posted: Apr 26, 2002 5:42 AM
Reply to this message Reply
Without knowing what you do, I believe you have classpath problem.
This is completely valid :
import java.util.*;
....
boolean[] a1 = new boolean[size];
Arrays.fill(a1, true);
...


This works well :
package test.lang;
 
import java.util.Arrays;
 
public class ArrayFill
{
  public static final int ARRAY_SIZE = 10;
  public static final String TRUE = " true";
  public static final String FALSE = " false";
 
  public static void main (String[] args)
  {
    boolean[] b = new boolean[ARRAY_SIZE];
    show (b);
    Arrays.fill (b, true);    
    show (b);
  }
  
  public static void show(boolean[] aBooleanArray)
  {
    StringBuffer buf = new StringBuffer ();
    buf.append ('[');
    for (int i = 0; i < (aBooleanArray.length-1); i++) 
      buf.append ((aBooleanArray[i]?TRUE:FALSE)).append(',');
      
    buf.append (' ')
          .append (aBooleanArray[aBooleanArray.length-1])
          .append (']');
    
    System.out.println ("b[] = " + buf.toString ());
  }
}
 


Output is

b[] = [ false, false, false, false, false, false, false, false, false, false]
b[] = [ true, true, true, true, true, true, true, true, true, true]



Thomas SMETS,
SCJP - Brussels

tech illin

Posts: 3
Nickname: illin
Registered: Apr, 2002

Re: how to do configuration to load java standard library? Posted: Apr 26, 2002 7:32 PM
Reply to this message Reply
Thanks for your reply at first.

I found it is interesting.
To use Arrays class, "import java.util.*" doesn't work, but "import java.util.Arrays" works.
And To use other classes like Random, "import java.util.*" works.

So now in my program, I have to type
import java.util.*;
import java.util.Arrays;

Is it funny?

Thomas SMETS

Posts: 307
Nickname: tsmets
Registered: Apr, 2002

Re: how to do configuration to load java standard library? Posted: Apr 28, 2002 10:06 AM
Reply to this message Reply
I believe you have a classpath problem period.
What is :
_ your OS ?
_ your VM version ?
_ What is your IDE ?
_ Have you special libraires ?
_ ... any other specifics ... ?

An IDE that would force you to import classes one at a time is doing a good (but annoying) job !

Give us more new to try to help you further !

Thomas SMETS,
SCJP, Brussels

tech illin

Posts: 3
Nickname: illin
Registered: Apr, 2002

Re: how to do configuration to load java standard library? Posted: May 8, 2002 6:40 PM
Reply to this message Reply
Thank you for your concern.
my OS is windows2000
VM is jdk1.3.1
no specific IDE, I use Textpad4.5 to edit, and run java command from an option of Textpad.
no special library now. I am just trying to link to java.util.* . It seems that I cannot link with the *.

Thomas SMETS

Posts: 307
Nickname: tsmets
Registered: Apr, 2002

Re: how to do configuration to load java standard library? Posted: May 9, 2002 2:40 AM
Reply to this message Reply
Just do the following !
In the task bar :
Start
|______Run
Type in there "cmd" (w/o the quotes of course).
then in the Dos prompt you have type :
"set"
or
"echo %classpath%"
You should have a reference to the file "rt.jar" in the classpath variable

Thomas SMETS,
SCJP 2 - Brussels

Flat View: This topic has 5 replies on 1 page
Topic: java image filter algo Previous Topic   Next Topic Topic: Base Number Program

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use