This repository has been archived by the owner on Feb 17, 2020. It is now read-only.
/
BUG_java.note
45 lines (36 loc) · 1.5 KB
/
BUG_java.note
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
[P PROJECT] Java
*******************************************************************************
*******************************************************************************
[b date] 11/14/2016
[b library] test.java
*******************************************************************************
[R BUG] When using "javac -cp <arg_1> <arg_2>" to compile java codes using the
stdlib.jar file, the compiler could not find the package. I had tried
//codebegin
import stdlib;
// or put it into a sub-directory "lib"
import lib.stdlib;
//codeend
Somebody in StackFlow said that stdlib.jar is not a package. Though I did
not import it in the class, other errors still occurred during compiling.
[G SOL] It turned out that I have to do "javac -cp .;stdlib.jar test.java" - notice
the ".;".
To run the executable file, I have to specify the class path again:
"java -cp .;stdlib.jar SortArray".
The following code is working
//codebegin
import java.util.Arrays;
class SortArray
{
public static void main(String[] args)
{
int[] array = {3, 5, 7, 8, 1, 0, 9};
Arrays.sort(array);
for(int i = 0; i < array.length; i++)
{
// System.out.print(array[i]);
StdOut.print(array[i]);
}
}
}
//codeend