Solution: the declared package .. does not match the expected package .. 2010-11-10
The package name must be specified through the package statement in the Program (for example, package org. it), rather than simply specifying the package by the directory structure.The directory structure is required only after the package name is available. The actual class name is org. it315.classname. Package sound must be setPut it at the beginning of the source file, and each source file can only declare one package at most (it is best to declare the package to develop a good coding style and habits)). For example: Testpackage. Java Package org. it; Public class testpackage { Public static void main (string [] ARGs) { System. Out. println ("test use package "); } } Suppose the directory is: e:/Eclipse/webeclipse/testproject/src/org/it Directly perform the following operations in DOS: Compile: e:/Eclipse/webeclipse/testproject/src/org/It> javac testpackage to generate testpackage. ClassThe file is located in the E:/Eclipse/webeclipse/testproject/src/org/IT/directory. Run: e:/Eclipse/webeclipse/testproject/src> JAVA org. It. testpackage to get the correct output. Be sure to pay attention to the path problem here. In addition, the package name and structure must be consistent with the relevant directory name, including case sensitivity.. However, in eclipse, because a new package is usually created first, the directory is automatically created for you when eclipse creates a package, so noWill be inconsistent. Eclipse generates the org/IT/directory under the corresponding testproject/bin directory, and generatesTestpackage. Class file, but in fact the name of this class is org. It. testpackage. Class. Of course, in eclipseIt can be run directly, but under the doscommand, you must pay attention to the actual compiling and running paths and class names. |
Solution:
Access restriction: The type base64decoder is not accessible due to restriction base64decoder and import sun. Misc. base64decoder are used when writing Java code in myeclipse. However, the eclipse prompt is as follows:
Access restriction: The type base64decoder is not accessible due to restriction on required library C: \ Program
Files \ Java \ jre6 \ Lib \ RT. Jar
Access restriction: the constructor base64decoder () is not accessible due to restriction on required library c: \ Program Files \ Java \ jre6 \ Lib \ RT. Jar
Solution 1 (recommended ):
You only need to remove the JRE System Library first in the Project Build path, and then add the library JRE system library. After re-compilation, everything will be normal.
Solution 2:
Windows-> preferences-> JAVA-> compiler-> errors/warnings->
Deprecated and trstricted API-> forbidden reference (access rules):-> change to warning solution: Role and usage of volatile in Java
Each time a member variable modified by volatile is accessed by a thread, the value of the member variable is forcibly re-read from the shared memory. In addition, when the member variables change, the thread is forced to write the change value back to the shared memory. In this way, two different threads always see the same value of a member variable at any time. In the Java language specification, it is pointed out that in order to get the best speed, the thread is allowed to save the private copy of shared member variables, and the original value of shared member variables is compared only when the thread enters or leaves the synchronized code block. In this way, when multiple threads interact with an object at the same time, you must notice that the thread needs to get the shared member variable changes in a timely manner. The volatile keyword prompts VM: For this member variable, it cannot store its private copy, but should directly interact with the shared member variable. Suggestion: use volatile on the member variables accessed by two or more threads. You do not need to use this variable when it is already in the synchronized code block or a constant. Because volatile is used to block the necessary code optimization in the VM, the efficiency is relatively low. Therefore, this keyword must be used when necessary. Just like in C, compiler optimization is prohibited ~~~~