Click here to Skip to main content
15,902,635 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I got an undocumented Java program left by previous developers. This is very usual at Taiwan. Is there any ways that I can shorten the trial-error to know how to run it correctly? That's, how can I find main method in classes among the program files?

Under 'com' and 'javax' are lots of .class files distributed in trees. Under META-INF is just a .MF file.

Could help me? Thanks.

It looks like:

 D:\programs\Decode_MMI_&_RU 2.6 的目錄

2018/08/31  下午 02:18    <DIR>          .
2018/08/31  下午 02:18    <DIR>          ..
2018/08/29  下午 04:34    <DIR>          com
2004/12/10  上午 11:45           110,681 commons-beanutils.jar
2004/12/10  上午 11:45           165,119 commons-collections.jar
2004/12/10  上午 11:45            93,881 commons-digester.jar
2004/12/10  上午 11:45            18,404 commons-logging-api.jar
2004/12/10  上午 11:45            26,388 commons-logging.jar
2004/12/10  上午 11:45           585,260 jasperreports-0.6.1.jar
2018/08/29  下午 04:34    <DIR>          javax
2018/08/30  下午 06:22                30 Manifest.txt
2018/08/29  下午 04:34    <DIR>          META-INF
2018/08/30  下午 06:35               342 MyJar.jar
2018/08/31  下午 02:18                 0 yy
               9 個檔案       1,000,105 位元組
               5 個目錄  40,881,438,720 位元組可用


What I have tried:

I tried to search solutions using google and in codeproject in vain.
Posted
Updated 31-Aug-18 0:06am
Comments
Richard MacCutchan 31-Aug-18 3:32am    
There is no easy way to find that in class files. You could try the obvious and run MyJar.jar to see what happens. Oh, and find the person who left this pile of elephant droppings and give him a good kicking.
Stan Huang 31-Aug-18 5:19am    
Yes, I've got the same idea with you to try to run MyJar.jar, but it responsed with error message: MyJar.jar 中沒有主要資訊清單屬性

The Chinese text means roughly "no main information of list characteristic."

As for the original developers, I am not sure they are in the heaven or hell. :)

1 solution

That sounds like it may be that there is no main class in that jar. You could try looking in the Manifest.txt file, and also any text files inside the META-INF directory. The manifest for the jar file should contain the name of the main class. You can always extract the manifest from any jar archive by using the following commands in a command window:
# list the contents of the archive
jar -tvf MyJar.jar // or whatever the file name is

# extract a file or files
jar -xvf MyJar.jar name_of_file_to_extract name_of_next ...
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900