Tag Archives: java

[Solved] Hadoop Error: Exception in thread “main“ java.io.IOException: Error opening job jar: /usr/local/hadoop-2.

An exception occurred while running MapReduce task today:
at first, I thought it was my JDK version. The JDK version of Linux was 1.8 and my windows JDK version was 11.0. I changed the JDK environment variable to 1.8, but the problem remained the same after running.

Later, I checked the size of the jar package and found that it was 0kb. Er… I checked the size of other jar packages, no problem. Then I think the jar package is damaged
I transported it through the window again, and it can succeed later

I hope this article is helpful to you~

Project Startup Error: Error running ‘xxxApplication‘;Command line is too long, Shoerten command line for……..

Springboot startup project error

When you start a project, you can’t start it all the time. The name of the startup class is too long. As shown in the figure below

Error running'XxxApplication';
Command line i stoo long. Shorten command line for XxxApplication or also for Spring Boot default configuration?

Modify idea configuration information

Enter the startup class configuration, click eidt configurations, and find the startup class:
in the short command line option, select the jar manifest option, because the default is the first none,

Explanation:

none :

 This is the default option and idea will not shorten the command line. If the command line exceeds the OS limit, the idea will not run your application, but the tooltip will suggest configuring a shortener.

JAR manifest:

idea passes long class paths through a temporary classpath.jar. The original class path is defined in MANIFEST.MF as the class path property in classpath.jar.

classpath file:

idea writes a long class path to a text file.

Online advice is to choose the third option, classpath file. You can choose according to your project needs

How to Solve JUnit Debugging initializationerror ERROR

**When I was doing the unit test @test, I suddenly found that the execution could not be done, and the following showed Junit initialization error initializationError!
Notes.
1. test method must be modified with public
2. The return value must be void
3. The method can not have parameters
4. The package can not have the class name Test class
5. Delete the path to the package from the new package, select JUnit4 or JUnit5 switch debugging
6. Remove the @Ignore annotation on the main class, if you add the following failure and do not execute **
package com.test.junit;
import static org.junit.Assert.*;
import org.junit.Ignore;
import org.junit.Test;
@Ignore 
public class FirstTest {
	String str1 = "===========TEST1===============";
	String str2 = "===========TEST2===============";
	@Test
	public void test1() {
		System.out.println(str1);	
	}
	@Test
	public void test2() {
		System.out.println(str2);
	}

**7. Some people say to reduce the version of JUnit, and others say to import other jar packages. Attach the version **

		<dependency>
			<groupId>org.hamcrest</groupId>
			<artifactId>hamcrest-core</artifactId>
			<version>1.3</version>
			<type>pom</type>
		</dependency>
		<dependency>
			<groupId>org.hamcrest</groupId>
			<artifactId>hamcrest-library</artifactId>
			<version>1.3</version>
			<type>pom</type>
		</dependency>

**Eclipse users, all know the Ctrl + S save and three clean, maven Update object, object clean and so on,
If it does not work, create a new identical project -> according to the previous content of the exact same import
(project file is small, it is recommended to import manually, do not copy and paste to avoid the previous error) -> run on success **

How to Solve [error] malformed \uxxxx encoding Error

Run the project with idea today. When you want to package directly, the result is that the packaging fails and an error is always reported   [ERROR] Malformed \uxxxx encoding.

After checking on the Internet, it has been said that there are paths that use errors when using slashes. It’s good to replace “\” with “/”, but there is no “\” in my configuration file and POM file.

In addition, let’s change the Maven warehouse and download the jar package again, but there are a lot of jars in my project, and some jars need to be imported manually. It must be unrealistic to download again with another Maven.

Until I saw an article later, MacOS – java.lang.illegalargumentexception: malformed \ uxxxx encoding while MVN install – stack overflow

The solution given in the article is to find the path to the library in the./m2/folder and delete it.

But

I still don’t have this folder.

Later, I searched the resolver-status.properties file globally using everthing, and found several. And look at the generation time, it was generated in the process of my packaging failure.

When I opened the file, I found that the error information of each package was recorded, and some of them were garbled.

So I deleted all resolver-status.properties generated during my packaging failure,

Then MVN install again with idea, and the project is packaged successfully.

So unify the following online solutions

1. First, check whether there are path errors in the. Properties,. YML, pom.xml, logback and other configurations of the project

2. Update the Maven repository and download the jar package again

3. Delete the path to the library or resolver-status.properties file

In either case, it is recommended to restart the editor. For idea, directly click the invalidate caches/restart button to clean up the cache and restart the idea

Like the second, it is unnecessary to update Maven warehouse. It is not necessary to download all jars again. You can download some jar packages that have not been downloaded successfully again.

How to judge whether the dependent download failed

Generally, unsuccessful downloading of dependencies will generate a file with the suffix not .Lastupdated. Once this file is generated, the dependencies will always fail to download. No matter how to reload Maven warehouse, the download will fail. It seems that when Maven checks the local library and checks the suffix file, it doesn’t seem to download the current dependency again.

Changing the Maven warehouse address is actually a new empty folder. In this way, the dependency will be downloaded again. Changing the dependent version is actually a new empty folder. Because the dependencies of each version will be placed in a separate folder

In this way, deleting files with the suffix .Lastupdated directly eliminates the need to update the Maven warehouse. In this way, successful downloads do not need to be downloaded again.

Of course, sometimes, we don’t know that the dependencies are not downloaded successfully, and only the .Lastupdated file is generated. Then, we can write a bat script to traverse all dependencies under the Maven warehouse, check whether the file suffix is .Lastupdated, and delete it if necessary. After the deletion is completed, use idea reload to the Maven warehouse again to download the dependencies again.

The script is as follows:

@echo off
::REPOSITORY_PATH replace with your own maven address
set REPOSITORY_PATH=D:\data\maven\maven-3.8.1-repository
echo %REPOSITORY_PATH%
for /f "delims=" %%i in ('dir /b /s "%REPOSITORY_PATH%\*lastUpdated*"') do (
    del /s /q %%i
)
pause

1. Create a new TXT file on the desktop, copy the contents above, and replace your Maven warehouse address.

2. Change the suffix of TXT file to. Bat and save the file

3. Double click to run the bat script.

This will delete all the .Lastupdated files in your Maven warehouse, and then you can download the jar package again

Eclipse Error: Could not create the Java Virtual Machine Error:A fatal exception has occurred

As a Xiaobai, this is a real headache. What you find on each platform is inconsistent, such as deleting three java files under system32, reconfiguration, etc. Finally, you find that Java becomes version 17? Just uninstall

(java17 has been uninstalled, so there is no control panel — program — uninstaller)

After uninstall

Just configure the Java environment normally

[Solved] Error: Could not create the Java Virtual Machine. Error: A fatal exception has occurred.

Error: could not create the Java virtual machine.
error: a fatal exception has occurred.program will exit

After I reinstalled eclipse, Tomcat reported this error when running JSP
Google has various solutions, some say Java, some say JDK, and some say Tomcat. They can’t use

Solution: just reset a workspace

[Solved] JAVA Error: Error:A JNI error has occurred,please check your installation and try again

Error message

Solving process

According to the error information, the reason for the error is that the version of the compiled Java code is different from the current version of java used for running. And the compiled version only supports running versions of 52.0 or above. Thus, it can be seen that the Java version currently used for running is lower than 52.0. First of all, you need to understand what is the compiled version and what is the running version. That is, we need to distinguish JRE from JDK.

When we install the Java environment, one version will correspond to two folders, JRE and JDK. JRE represents the Java runtime environment, that is, the Java runtime environment, while JDK represents the Java se development kit (JDK), that is, the Java compilation environment. We can check whether the versions of the two environments are consistent in CMD (as shown in the following figure):
java – version views the version of JRE (running environment). Javac – version looks at the version of JDK (compilation environment). Note: if you cannot successfully view the version by entering the above command, it indicates that there is a problem with the environment configuration. Please refer to here. Back to the point, if you find inconsistencies after checking the version, reconfigure the environment to ensure that the version is consistent and then recompile and run. It should be noted that I didn’t write the code here, and only got the compiled class file, so I can only solve this problem by changing the running java version. From the error message, we can know that after compilation, this code only supports the JRE environment of java version 52.0 or above. Even if we don’t know which java version 52.0 corresponds to, it must be higher than 1.8.0. In order to avoid problems in the future, I plan to directly update the entire java version, that is, replace JDK and JRE with a new version. Also, considering that 1.8.0 may be needed in the future, I will not delete the 1.8.0 version.

Solution

First download the Java version of 1.9, that is, download the installation package of jdk9.0 (JDK package includes JDK and JRE, 9.0 is 1.9). Here is the network disk link of (windows-x64)
extraction code: 63q0 after downloading and installing, you can start configuring the environment. In order to facilitate management, I put 1.9 under the same path as the previous 1.8. As shown in the following figure:
modify the original Java in the system variable_ Home and JRE_ Home path to point to the newly installed java version of 1.9 (if the way to configure the environment is different from mine, it doesn’t matter. In essence, it’s just that the path to point has changed. I suggest this way to configure it for management convenience. Please refer to the configuration link provided above). As shown below


Check the versions of JDK and JRE again (remember to re open CMD after confirmation)
run the code again and run successfully

OTA Pack Compile Error: ExternalError: Failed to run signapk.jar: return code 1:Error: A JNI error has occurred

Android 11 reports an error during OTA package:

ExternalError: Failed to run signapk.jar: return code 1:
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.UnsupportedClassVersionError: com/android/signapk/SignApk has been compiled by a more recent version of the Java Runtime (class file version 53.0), this version of the Java Runtime only recognizes class file versions up to 52.0
	at java.lang.ClassLoader.defineClass1(Native Method)
	at java.lang.ClassLoader.defineClass(ClassLoader.java:756)
	at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
	at java.net.URLClassLoader.defineClass(URLClassLoader.java:468)
	at java.net.URLClassLoader.access$100(URLClassLoader.java:74)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:369)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:363)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:362)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
	at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:601)

According to the error analysis, it is caused by the jdk version.

1. First check the jdk version: java –version My previous version was openjdk-8
2. Use sudo apt-get install openjdk-11-jdk to install openjdk-11
3. Configure linux default jdk version: sudo update-alternatives –config java, select the JDK version you need
4. Configure the default java version: sudo update-alternatives –config javac, select the java version you need.

Just do the ota package again.