Path to the Java jar package

Source: Internet
Author: User

Using Java scripts and then running into a jar package, the program in the jar package needs to read some parameters of the configuration file, so you need to determine the path to the read configuration file. The general configuration file and the jar package are placed in the same directory, this time requires the code in the jar package, fetch the path of the jar package, in order to read the configuration file, the code to take the jar package storage path is as follows:

String Jarwholepath = DbfImport.class.getProtectionDomain (). Getcodesource (). GetLocation (). GetFile ();
Jarwholepath = Java.net.URLDecoder.decode (Jarwholepath, "UTF-8");
String jarpath = new File (Jarwholepath). Getparentfile (). GetAbsolutePath ();

Path to the Java jar package

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.