Tag Archives: experience

Error: Could not find or load main class ***

Question:
Javac compiles the source code and executes the Java Mainclassname Error: Could not find or Load main class *** Error
The reason:
The runtime cannot find the main class, either because it did not write the full name of the main class (it requires the full package name) or because it wrote the wrong name of the main class (not the name of the main class, but the file name of the main class), or because it did not specify a directory with the classpath.
Solution 1:
Java classpath – [classpath directory] package1, package2. Mainclassname
Such as:
Run the command as in ***/target/classes/hello directory
java -cp ../hello/HelloWorld
or
java -cp ../hello. The HelloWorld
(-classpath here can also be -cp.)
Note that the path after 1: -classpath is in the directory of the top-level package name (package1) and in the directory of the package1 folder (if the source program does not start with any packages, that is the current compiled directory, -cp./ The current path can be without specifying the -cp parameter), or.. Relative or absolute paths to /target/classes/
Note 2: run the file must be full name, to add all the package name (if you have any package program starts packagename) until the main class name, such as: packagename. Mainclassname (note that there is the main class name for the file name is not the main class, also is not generated by the * * *. The class files, is the main method in the name of the class)
Solution 2
The directory from CD to the classpath, if there is a package name (the directory where the top-level package name package1 folder is located, or.. If the source program does not have a package at the beginning, run the following command in the path of the ***.class file after compilation.
Java package1. Package2. Mainclassname
Such as:
Run the following command in the ***/target/classes directory where the package name hello resides
Java hello/HelloWorld
or
Java hello. The HelloWorld
Conclusion:
The problem is that the main class cannot be found, it must run with the full main class name including the package name, and it needs to specify the directory of the class path.
Appendix:
Java usage methods and parameters table after running Java-help
Usage: java [-options] class [args…]
(to execute a class)
or Java [-options] -jar jarfile [args…]
(to execute a jar file)
where options include:
-d32 use a 32-bit data model if available
-d64 use a 64-bit data model if available
-server to Select the “server” VM
the default VM is server.
– cp & lt; class search path of directories and zip/jar files>
– the classpath & lt; class search path of directories and zip/jar files>
A: separated list of directories, JAR archives,
and ZIP archives to search for class files. name> =< value>
set a system property
-verbose :[class|gc|jni]
enable verbose output
-version print product version and exit
-version :< value>
Warning: This feature is deprecated and will be removed
in a future release.
requires the specified version to run
-showversion print product version and Restrict-search continue
-re-search restricb-no-re-search
Warning: continue
-re-search restricb-search Removed
in a future release.
include/exclude user private JREs in the version search
-?-help print this help message
-x print help on non-standard options
-ea [:<packagename>…|:<classname> classname>] [: & lt;
– enableassertions packagename>… | : & lt; classname>]
enable assertions with specified granularity
-da [:<packagename>…|:<classname>] [: & lt;
the -disableassertions packagename>… | : & lt; classname>]
disable assertions with specified coverage
-esa | -enablesystemassertions
enablesystem enabling
-dsa |-disablesystemassertions
Disable the system assertions
– agentlib: & lt; libname> [=<options>]
load native agent library < libname> -agentlib:hprof
see also, -agentlib: JDWP =help and -agentlib:hprof=help
-agentpath :< pathname> [=<options>]
load native agent library by full pathname
-javaagent :< jarpath> [=<options>]
load Java programming language agent, see java.lang. Instrument
-splash :< imagepath>
show splash screen with the specified image
See http://www.oracle.com/technetwork/java/javase/documentation/index.html for more details.
Helloworld.java :(notice the package name)

package hello;

public class HelloWorld {
    public static void main(String[] args) {
        Greeter greeter = new Greeter();
        System.out.println(greeter.sayHello());
    }
}

Greeter.java

package hello;

public class Greeter {
    public String sayHello() {
        return "Hello world!";
    }
}

Reference:
https://stackoverflow.com/questions/18093928/what-does-could-not-find-or-load-main-class-mean

Error: more than one row returned by a subquery used as an expression

Reason for error: There are multiple pieces of data with ID =1, but the code USES a single value to receive it.
Case study: Query the user whose age is 1. There are a lot of users in the database whose age is 1, but the code is received with an int, which causes this error to occur

dao: public int get(int age);
xml:
<select id = “get” resultType=“java.lang.Integer”>
	select age from user where age = 1;
</select>

The correct code is:

dao: public List<Integer> get(int age);
xml:
<select id = “get” resultType=“java.lang.Integer”>
	select age from user where age = 1;
</select>

Win10 install iTunes appears: “installation assembly microsoft.VC80 . CRT, tupe = Win32, version = 8.0.50727.6195 “…”

There is an error installing ITunes64setup.exe, “Install assembly Microsoft.vc80.crt, Tupe =” Win32 “, Version =”8.0.50727.6195″, publicKeytoken=” 1FC8b3B9A1e18e3B “, processorArchitecture=”x86”.
solution:
press Win+R to run, type services.msc, launch the service, find the Windows Module Installer, right-click, and choose start. If it starts successfully, try the installation again.

If the prompt “Windows Module Installer cannot start and the specified Module cannot be found” is a registry missing TrustedInstaller entry. You can check whether the registry has this or export it from the same WIN10 system if it does not. HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\TrustedInstaller
 
Before installing iTunes, you need to install the security update “Microsoft Visual C ++ 2005 Service Pack 1 Redistributable Component Pack ATL Security Update”. Download and install: Microsoft Visual C ++ 2005 Service Pack 1 redistributable Component Pack ATL security updates
 
If: Error 1935. Installation assembly Microsoft-vc80.atl,type=”win32″,version=”8.0.50727.762″
That’s because the previous installation of some software limited the size of the registry. The solution is to enter regedit into the registry in the start window. Find the HKEY_LOCAL_MACHINE \ System \ CurrentControlSet \ Control. Note that with Control selected, select the RegistrySiziT (REG_DWORD type) on the right and change the value to FFFFFFFF (base 10 is 4294967295) to start the Windows Module Installer after restarting the computer.

 
If you’ve installed a previous version of iTunes, make sure all iTunes launches are open before restarting.
This completes the installation.

Error while instantiating ‘org.apache.spark.sql.hive.HiveExternalCatalog’:

Using Spark-shell to connect to external Hive, the following error occurs:

[diao@hadoop111 spark-2.1.1]$ bin/spark-shell 
19/08/13 14:15:52 WARN NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
19/08/13 14:15:57 WARN HiveConf: HiveConf of name hive.conf.hidden.list does not exist
19/08/13 14:15:59 WARN HiveConf: HiveConf of name hive.conf.hidden.list does not exist
java.lang.IllegalArgumentException: Error while instantiating 'org.apache.spark.sql.hive.HiveSessionState':
  at org.apache.spark.sql.SparkSession$.org$apache$spark$sql$SparkSession$$reflect(SparkSession.scala:981)
  at org.apache.spark.sql.SparkSession.sessionState$lzycompute(SparkSession.scala:110)
  at org.apache.spark.sql.SparkSession.sessionState(SparkSession.scala:109)
  at org.apache.spark.sql.SparkSession$Builder$$anonfun$getOrCreate$5.apply(SparkSession.scala:878)
  at org.apache.spark.sql.SparkSession$Builder$$anonfun$getOrCreate$5.apply(SparkSession.scala:878)
  at scala.collection.mutable.HashMap$$anonfun$foreach$1.apply(HashMap.scala:99)
  at scala.collection.mutable.HashMap$$anonfun$foreach$1.apply(HashMap.scala:99)
  at scala.collection.mutable.HashTable$class.foreachEntry(HashTable.scala:230)
  at scala.collection.mutable.HashMap.foreachEntry(HashMap.scala:40)
  at scala.collection.mutable.HashMap.foreach(HashMap.scala:99)
  at org.apache.spark.sql.SparkSession$Builder.getOrCreate(SparkSession.scala:878)
  at org.apache.spark.repl.Main$.createSparkSession(Main.scala:96)
  ... 47 elided
Caused by: java.lang.reflect.InvocationTargetException: java.lang.IllegalArgumentException: Error while instantiating 'org.apache.spark.sql.hive.HiveExternalCatalog':
  at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
  at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
  at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
  at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
  at org.apache.spark.sql.SparkSession$.org$apache$spark$sql$SparkSession$$reflect(SparkSession.scala:978)
  ... 58 more
Caused by: java.lang.IllegalArgumentException: Error while instantiating 'org.apache.spark.sql.hive.HiveExternalCatalog':
  at org.apache.spark.sql.internal.SharedState$.org$apache$spark$sql$internal$SharedState$$reflect(SharedState.scala:169)
  at org.apache.spark.sql.internal.SharedState.<init>(SharedState.scala:86)
  at org.apache.spark.sql.SparkSession$$anonfun$sharedState$1.apply(SparkSession.scala:101)
  at org.apache.spark.sql.SparkSession$$anonfun$sharedState$1.apply(SparkSession.scala:101)
  at scala.Option.getOrElse(Option.scala:121)
  at org.apache.spark.sql.SparkSession.sharedState$lzycompute(SparkSession.scala:101)
  at org.apache.spark.sql.SparkSession.sharedState(SparkSession.scala:100)
  at org.apache.spark.sql.internal.SessionState.<init>(SessionState.scala:157)
  at org.apache.spark.sql.hive.HiveSessionState.<init>(HiveSessionState.scala:32)
  ... 63 more
Caused by: java.lang.reflect.InvocationTargetException: java.lang.reflect.InvocationTargetException: java.lang.RuntimeException: java.lang.RuntimeException: The root scratch dir: /opt/modules/hive on HDFS should be writable. Current permissions are: rwxrwxr-x
  at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
  at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
  at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
  at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
  at org.apache.spark.sql.internal.SharedState$.org$apache$spark$sql$internal$SharedState$$reflect(SharedState.scala:166)
  ... 71 more

Modify the Hive-site.xml file
Prefixes the value with HDFS :// hadoOP111:8020

<property>
    <name>hive.exec.scratchdir</name>
    <value>hdfs://hadoop111:8020/opt/moules/hive</value>
  </property>

It will run successfully after modification

[diao@hadoop111 spark-2.1.1]$ bin/spark-shell 
19/08/13 14:22:32 WARN NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
19/08/13 14:22:38 WARN HiveConf: HiveConf of name hive.conf.hidden.list does not exist
19/08/13 14:22:40 WARN HiveConf: HiveConf of name hive.conf.hidden.list does not exist
19/08/13 14:22:42 WARN ObjectStore: Failed to get database global_temp, returning NoSuchObjectException
Spark context Web UI available at http://192.168.253.111:4040
Spark context available as 'sc' (master = spark://hadoop111:7077, app id = app-20190813142233-0003).
Spark session available as 'spark'.
Welcome to
      ____              __
    /__/__  ___ _____/ /__
    _\ \/ _ \/ _ `/ __/  '_/
   /___/ .__/\_,_/_/ /_/\_\   version 2.1.1
      /_/
         
Using Scala version 2.11.8 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_202)
Type in expressions to have them evaluated.
Type :help for more information.

woeusb Installation failed Exit code 256

possible solutions :

the first type:

in Windows system (can open virtual machine), use Rufus to make the startup disk

second:

on the command line, get administrator privileges, on the command line to start running this application (GUI)

the third:

on the command line, using the woeusb command, complete the creation of the boot disk (without using the graphical interface).

if you are working on a Linux system, you can use gnome’s own application, disk image writer.

if you are making a Windows system, or use Windows computer tools to do it (more convenient)!