Tag Archives: java

Idea update failure problem: couldn’t save uncommitted changes solution

An error occurred during the update of the project today, which could not be solved after a long period of debugging.
error reason:

  Couldn't save uncommitted changes.
  Tried to save uncommitted changes in stash before Update, but failed with an error.
  Couldn't stash file://H:/IdeaProjects/SVSP_0.4: git-write-tree: error building trees
  Cannot save the current index state

After gradual investigation, it was found that colleagues uploaded redundant files, which caused the collective failure to update. The solution is as follows:
Enter

    into your project directory. My directory is H:\IdeaProjects\ svsp_0.4 . Right-click on Git Bash here and type Git status. Notice the Unmerged paths
Unmerged paths:
  (use "git reset HEAD <file>..." to unstage)
  (use "git rm <file>..." to mark resolution)
        both deleted:    .idea/artifacts/SVSP0_4.xml
    was found because there were extra files uploaded, and both deleted: followed by .idea/artifacts/ svsp0_4.xml this file is typed in git rm.idea /artifacts/ svsp0_4.xml and then enter the idea update to resolve the problem

Listener refused the connection with the following error: ORA-12505, TNS:listener does not currently

Error using Java connection oACLE12C:
java.sql.SQLException: Listener refused the connection with the following error:
ORA-12505, TNS:listener does not currently know of SID given in connect descriptor
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:673)
at oracle.jdbc.driver.PhysicalConnection.< init> (PhysicalConnection.java:711)
at oracle.jdbc.driver.T4CConnection.< init> (T4CConnection.java:385)
at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:30)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:558)
at java.sql.DriverManager.getConnection(DriverManager.java:664)
at java.sql.DriverManager.getConnection(DriverManager.java:247)
at demo1.DBHelp.getCon(DBHelp.java:16)
at demo1.DBHelp.main(DBHelp.java:28)
Caused by: oracle.net.ns.NetException: Listener refused the connection with the following error:
ORA-12505, TNS: listener does not currently know of SID given in the connect descriptor

the at oracle.net.ns.NSProtocolStream.negotiateConnection (NSProtocolStream. Java: 272)
the at oracle.net.ns.NSProtocol.connect(NSProtocol.java:263)
at oracle.jdbc.driver.T4CConnection.connect(T4CConnection.java:1360)
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:486)
. 8 more
obviously, this is because the listener cannot recognize the database SID in the connection identifier, go to the network to look up
The solution online is as follows: find the tnsnames.ora file and open it using Notepad or another tool. Note that this is the path of the ORACLE 12C file and different versions of Oracle are in different paths
D:\oracle\app\Administrator\product\12.1.0\dbhome_1\NETWORK\ADMIN tnsnames.ora

# tnsnames.ora NETWORK Configuration File: D:\oracle\app\Administrator\product\12.1.0\dbhome_1\network\admin\tnsnames. Ora
# Generated by oracle configuration tools.

LISTENER_TEST =
(ADDRESS = (PROTOCOL = TCP)(HOST = Localhost)(PORT = 1521))

LISTENER_ORACLE12C =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))

ORACLR_CONNECTION_DATA =
(DESCRIPTION =
(ADDRESS_LIST) =
(ADDRESS = (PROTOCOL = IPC) (KEY = EXTPROC1521))

(CONNECT_DATA =

(SID = CLRExtProc) (the PRESENTATION = RO)

ORACLE12C =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521)))
(CONNECT_DATA =
(SERVER = oracle12c))
(SERVICE_NAME = oracle12c)
)
)
// Change the red part to the one shown above. The green part is the instance name of the database when you installed it.

D: Oracle \ App \Administrator\ Product \12.1.0\dbhome_1\NETWORK\ADMIN Listener. Ora file
The contents of the file are as follows:
# listener.ora Network Configuration File: D:\oracle\app\Administrator\product\12.1.0\dbhome_1\network\admin\listener. Ora
# Generated by oracle configuration tools.
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = CLRExtProc)
(ORACLE_HOME = D:\oracle\app\Administrator\product\12.1.0\dbhome_1)
(PROGRAM = extproc)
(ENVS = “EXTPROC_DLLS = ONLY: D: \ oracle \ app \ Administrator \ product \ 12.1.0 \ dbhome_1 \ bin \ oraclr12 DLL”)
)

 (SID_DESC =
(GLOBAL_DBNAME = oracle12c)
(ORACLE_HOME = D:\oracle\app\Administrator\product\12.1.0\dbhome_1)
(SID_NAME = oracle12c)
)

)
LISTENER =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
)

The red part is to add, save, and then restart the Oracle service.
The content of the test is shown below
package demo1;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class DBHelp {
private static String URL = “JDBC :oracle:thin:@127.0.0.1:1521:oracle12”;
private static String USERNAME = “system”;
private static String PASSWORD = “940109”;
public static Connection getCon(){
Connection conn = null;
try {
Class.forName(“oracle.jdbc.driver.OracleDriver”);
conn = DriverManager.getConnection(URL,USERNAME,PASSWORD);
if(conn! =null)
System.out.println(“connect successful”);
} catch (Exception e) {
e.printStackTrace();
}
return conn;
}
/**
* @param args
*/
public static void main(String[] args) {
System.out.println(new DBHelp().getCon());
}
public static void close(Connection con,Statement sm,ResultSet rs){
try {
if(con! =null){
con.close();
}
if(sm! =null){
sm.close();
}
if(rs ! = null){
rs.close();
}
} catch (SQLException e) {
e.printStackTrace();
}
}
}
// There will be no more errors
connect successful
oracle.jdbc.driver.T4CConnection@1edf1c96
In other words, when installing Oracle12c, I changed the name of the instance by myself. If it is installed according to the default instance, then the above content basically does not need to be modified by myself.
Is not installed as the default instance.

Support annot run git xcrun: error: invalid active developer path

The Mac upgraded the system and found Git broke in idea…   
Complete error message
С annot Run Git
xcrun: error: invalid active developer path (/ Library/developer/CommandLineTools), missing xcrun at:/Library/developer/CommandLineTools/usr/bin/xcrun

to see if Git can be used properly on the command line -help still registers the same error as above
In the search under git installation directory
Whereis the git
/usr/bin/git
The git installation location can be printed correctly
If there is a problem with the Git installation, brew Install Git is used again
Error: The following formula:
git
cannot be installed as a binary package and must be built from source.
Install The Command Line Tools:
xcode-select — Install
Error: Git must be installed and in your PATH!
Error: The following formula:
git
cannot be installed as a binary package and must be built from source.
Install The Command Line Tools:
xcode-select — Install
This error prompts xcode-select –install
Then use Xcode-select-install to solve the installation successfully

The console sees the successful output using the git –help command
Solution: use Xcode-select-install to complete the installation and restart idea
 

Java learning error information 3 — Java notes

Java common error messages and solutions

compile error

common compile error on Windows

‘javac’ is not recognized as an internal or external command, operable program or batch file.

this prompt indicates that the Windows system cannot find the compiler (compiler).

solution: (suppose the JDK installation location is C:\jdk1.7.0)

1. Include the JDK installation path on the command line;

& gt; C: \ jdk1.7.0 \ bin \ javac HelloWorldApp. Java

by default, the compiler (javac) is in the bin folder under the JDK installation path.

2. Include the JDK installation path in the Windows environment variable.

1) Start & gt; Control Panel > System > Advanced > Environment Variables;
(start > Control panel & GT; System & gt; Advanced system Setup & GT; Environment variables…) 2) add the bin PATH under the installed JDK to the PATH variable and remember to add the semicolon (;) .

PATH variable has a value of: < The end of the original PATH value & GT; ; C: \ jdk1.7.0 \ bin
After adding the PATH variable
, you can use the compiler (javac) directly from the command line without entering the PATH where the compiler is located.

Class names, “HelloWorldApp”, are only accepted if annotation processing is explicitly requested

found this prompt at compile time, indicating that the.java suffix was not added at compile time. The command to compile the Java file is Javac HelloWorldApp.java instead of Javac HelloWorldApp.

UNIX system common compile error

javac: Command not found

this prompt indicates that the compiler (javac) cannot be found for UNIX systems.

solution :(assume JDK installation location is /usr/local/jdk1.7.0)

1. Include the JDK installation path on the command line;

/usr/local/jdk1.7.0/javac HelloWorldApp. Java

is mainly where the compiler (javac) is added.
2. Modify the system PATH variable.

needs to be modified according to the Shell used, and different Shell modification methods are different.

Class name, ‘HelloWorldApp’, are only accepted if annotation processing is explicitly requested

this prompt is the same as in Windows, indicating that the filename on the command line was not added when compiling the file. Java suffix.

syntax Errors (all platforms) – Synatx Errors

the compiler displays a syntax error message when there is a typo in the program source file. The error message contains the file name of the error, line number, error type, error line code, and error code location.

as the following error message:

testing.java:14:’; ‘ expected.

System.out.println(“Input has ” + count + ” chars.”)

^

1 error

error file name: testing. Java

error line number: line 14

error message: semicolon (;) required

error line: system.out.println (“Input has “+ count +” chars.”)

error location: ^ indicates location, end of error code

error number: 1

multiple error messages are given if the compiler cannot accurately locate the error due to indenting, block scope, missing semicolon, etc.

any compilation error will indicate that the compilation was unsuccessful and the.class file will not be generated. You need to find and fix all compilation errors, and then recompile.

semantic error
In addition to checking the syntax, the
compiler also checks the underlying semantics, such as undefined variables, objects not instantiated being used directly, and so on.

runtime error

runtime error message on Windows/UNIX systems

Exception in thread “main” java.lang.NoClassDefFoundError: HellowWorldApp
An error above
indicates that the initiator program (Java) did not find a bytecode file (.class) that could be executed. By default, the Java launcher looks for the.class file that has been started in the current directory. You need to switch the current working directory to the directory containing the target.class file and execute Java HelloWorldApp again.

Could not find or load main class HelloWorldApp.class
The error message above
indicates that Java helloworldapp.class was executed. On the command line, the Java command should be followed by the required class name, not the.clAS file name. The correct execution is Java HelloWorldApp.

Exception in thread “main” java.lang.NoSuchMethodError:main
The error message above
indicates that the class being used does not contain a main function. The Java virtual machine requires that classes executed by Java commands contain a main function.

Ref: http://docs.oracle.com/javase/tutorial/getStarted/problems/index.html

CreateProcess error=193, %1 is not a valid Win32 application

 
Error: Failed to execute goal com. Making. Eirslett: frontend – maven – XXXXXXXX
You can perform MVN Clean Package-e viewing, which will wrap and display more detailed error information
The error message is CreateProcess error=193, %1 is not an valid Win32 Application.
The Frontend – Maven-Plugin’s GtiHub has an explanation for an error
https://github.com/eirslett/frontend-maven-plugin/issues/487
 

Eclipse startup error: an error has occurred.See the log file E:\workspace\.metadata\.log.

This is due to an eclipse shutdown exception, which you can resolve by following these steps:
1. Open the eclipse workspace E: \ eclipse \ workspace \. Metadata \. Plugins \ org eclipse. The core resources found. The projects files
So, open the projects file, and remove. Markers. Snap and. Syncinfo.snap from all projects from last started
3. Start Eclipse again and you’re done!

Solving the problem of can’t create temporary directory of CVS under Windows


cvs [server aborted]:
Can’t create temporary Directory C:\WINDOWS\TEMP/ CVS-SERV1320: Permission Denied problem.

The solutions to this problem are as follows:

First, modify the temporary directory of the CVS server (to restart the service after modification)

Then modify the corresponding temporary folder permissions, as follows:

1. Open any folder, click Tools – Folder Options on the menu, and select View in the popup window. As shown, unselect Use Sharing Wizard (Recommended) and click OK to close the window.

2. Open the properties of the temporary folder and modify the corresponding permissions in the security options

That is ok.

Cause check of unreachable statement exception in Java

Unsaid statement exceptions:
Reason 1:
The Java compiler flags an UnreachableStatement as a runtime error, and an unreachablestatement is when the compiler decides it will never execute it.
several things below are said to be unsaid statements:
(1) say the statement after the reutrn statement.
(2) writes the statement after the throw statement.
(3) break, continue statement after defining statement.
(4) “\u10100” // valid, equivalent to ‘\u1010’ and string ‘0’. The
(5) shift operator can be used with long int char short byte. The access control for the
(6) class can be public or nothing.
(7) goto is reserved but not key. Then it’s nothing.
(8) when casting the type of the superclass to an object assigned to a subclass, no exception is compiled, but an exception occurs at runtime.
Reason 2: the
unreachable statement is caused by a return operation that precedes the statement, or by other operations that make it impossible to execute the statement regardless of the condition.
most importantly: check to see if the previous statement returned, and see if any conditions were returned in front of the statement due to your own negligence, even without errors such as syntax.
Because of my own negligence, I have added if or for conditionals several times. Causes the following return statement not to execute any subsequent statements, but to return 1;
as shown in the picture:

must be careful and careful again!!

Bug001: error in gradle configuration environment variable: ERROR:JAVA_ Home is set to an invalid directory!

Gradle-v error: Error: Java_home is set to an invalid Directory :C:\Java\jdk1.8.0_05
please set the java_home variable in you environment to match the location of your java installation.
On the Internet turned over again, some people said more than a semicolon, some people said to change this change that, I erase, others try it, My zha change is not in, is really angry evil old man!
Look at the picture first:


But when I looked up, My eyes were fixed on it!

Vonema, how did you automatically leave out the “Program Files “?

Then Windows+R, CMD, gradle-V, and sure enough! Problem solved smoothly!!

 

Websocket code 200 error

WebSocket connection to ‘XXX’ fails: Error during WebSocket handshake: Unexpected Response code 200
This problem is mainly the problem of background, the front-end address access is yes
in my own configuration used in the project of the security framework of Shiro, because no open access permissions so appeared the error
it is good to open the access here

if it is not the problem can look for the background does not open access what
if the address was wrong will directly at 404 mistakes, instead of 200

【PTA:】 Error: class X is public should be declared in a file named X.java

(?: can not come out on the PTA error without looking at the _ (: з) <) _) I have been making this mistake in writing the topic on PTA today.
Error: class X is public should be declared in a file named X.java

Searched a lot of solutions, it is said that the class name and file name to change the same, obviously I changed is really the same duck. I also asked the strong brother big sister, how to change is reported this wrong (; ‘⌒ `)
.
Later, a classmate told me that it was the problem of PTA platform:

http://www.cnblogs.com/zhrb/p/6347738.html



The name of the class is the Main file names, at last it redone success.
a simple grinding by me so long, all want to broken head didn’t expect to be the problem (; ´ д `) ゞ
it is a good habit to look at the instructions