Summary of troubleshooting errors in eclipse

Source: Internet
Author: User

In progress todayCodeDuring the integration test, run-JUnit test is performed on the Java code of the integration test. The console should have printed the running information

 

 

 

As shown in the following figure:

 

 

I personally think it is quite curious, but there is no problem with other projects in the same workset.

 

According to the running principle of Eclipse, in fact, run-JUnit test is to execute javaw-classpath ***/**. similar jar ***/test commands are the same as run-application commands. Then a main method is added, and the expected result is the same. After the Run-application is run, the console displays the same result as the preceding one.

 

I started to think it was an eclipse problem or a code modification problem. I re-downloaded the Code and the new eclipse results are still the same. Then I confirmed the JVM version, all of them use the jdk1.6.0 _ 31 version. The previous versions are deleted, but the problem remains the same.

 

In reasoning, it is found that the code in other projects of workset can run, and it is found that the estimation is not closely related to eclipse and JVM. I think this project depends on a lot of jar packages. Is it related to this. First, some dependent jar packages are deleted (half deleted ).ProgramAnd the above error is not reported. I think the problem may occur here. It is preliminarily suspected that the classpath is too long to execute the Java W command.

All of our functional dependency jars are managed through MVN. By default, the MVN repository is c: \ Documents ents and Settings \ USERNAME \ repository. Therefore, each dependent jar package has this prefix, I will try to reduce this prefix first, so the default repo directory is directed to the D: \ repo directory, re-compile and execute the dependency, refresh the eclipse code, and run-application again, it is found that the program runs normally. Later I wrote a piece of code to verify my guess:

Public class test {public static void main (string [] ARGs) throws exception {stringbuilder sb = new stringbuilder (); sb. append ("javaw"); sb. append ("-classpath"); // construct a long path classpathfor (INT I = 0; I <1000; I ++) {sb. append ("D:/repo/log4j/log4j/1.2.13/log4j-1.2.13.jar,");} sb. deletecharat (sb. length ()-1); sb. append ("com. company. test. test "); system. out. println (sb. tostring (); // execute the command process = runtime.getruntime(cmd.exe C (sb. tostring (); // print the result list <string> List = ioutils. readlines (process. getinputstream (); For (string S: List) {system. out. println (s );}}}

 

When running this code, the printed result is the same as above. The result is as follows, which is in line with my guess.

Usage: javaw [-options] class [ARGs...] (to execute a class) or javaw [-options]-jar jarfile [ARGs...] (to execute a jar file) where options include: -Client to select the "client" VM-server to select the "server" VM-hotspot is a synonym for the "client" VM [deprecated] The default VM is client. -CP <Class search path of directories and zip/jar files>-classpath <Class search path of directories And zip/jar files> A; separated list of directories, Jar archives, and zip archives to search for class files. -d <name >=< value> set a system property-verbose [: Class | GC | JNI] Enable verbose output-version print product version and exit-version: <value> require the specified version to run-showversion print product version and continue-JRE-restrict-search |-JRE-no-restrict-search include/exclud E user private jres in the version search -? -Help print this help message-x print help on non-standard options-ea [: <packagename>... |: <classname>]-enableassertions [: <packagename>... |: <classname>] Enable assertions-da [: <packagename>... |: <classname>]-disableassertions [: <packagename>... |: <classname>] disable assertions-ESA |-enablesystemassertions enable system assertions-DSA |-disablesystemassertions disable system assertions-agentlib: <libname> [= <Options>] load native agent library <libname>, e.g. -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 specified Image

 

We printed the command and copied it to the CMD command line for execution. We found that the command line was incomplete and was automatically intercepted.

 

This command is not complete at all, and the class of the subsequent command is lost. The Java W parameter does not specify the class to be run, which leads to the result we see.

In Windows, this may be related to the length limit of shell commands.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.