[ 
https://issues.apache.org/jira/browse/SCB-725?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16539631#comment-16539631
 ] 

ASF GitHub Bot commented on SCB-725:
------------------------------------

WillemJiang commented on a change in pull request #799: [SCB-725] support get 
main class package when run with "java -jar xxx.jar
URL: 
https://github.com/apache/incubator-servicecomb-java-chassis/pull/799#discussion_r201578064
 
 

 ##########
 File path: 
foundations/foundation-common/src/main/java/org/apache/servicecomb/foundation/common/utils/JvmUtils.java
 ##########
 @@ -36,21 +42,50 @@ private JvmUtils() {
    * @return main class or null, never throw exception
    */
   public static Class<?> findMainClass() {
+    // 1.run with java -cp ......
+    //   command is main class and args
+    // 2.run with java -jar ......
+    //   command is jar file name and args
     String command = System.getProperty(SUN_JAVA_COMMAND);
     if (command == null || command.isEmpty()) {
       return null;
     }
 
-    // command is main class and args
-    String mainClass = command.trim().split(" ")[0];
+    String mainClassOrJar = command.trim().split(" ")[0];
+    String mainClass = readFromJar(mainClassOrJar);
+    if (mainClass == null || mainClass.isEmpty()) {
+      return null;
 
 Review comment:
   OK
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> support get main class package when run with "java -jar xxx.jar"
> ----------------------------------------------------------------
>
>                 Key: SCB-725
>                 URL: https://issues.apache.org/jira/browse/SCB-725
>             Project: Apache ServiceComb
>          Issue Type: Task
>          Components: Java-Chassis
>            Reporter: wujimin
>            Assignee: wujimin
>            Priority: Major
>




--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to