Java Packaging jar and path issues

Source: Internet
Author: User

1. The default current root directory of Eclipse is the directory where the project is located, that is, the first level of the SRC directory, the path is written from the SRC parent directory to find 2, This.getclass (). getClassLoader () default from the SRC directory to find files, That is, the root directory is SRC3, packaging jar after the default root is src, that is, the file from src start looking for 4, packaging jar get input stream can use This.getclass (). getClassLoader (). Getresouceasstream ("..")
5, in Eclipse often use refresh observation change 6, if the class to be packaged into a jar, then create a file in the class cannot use the full path, that is,String Path = This.getclass (). GetResource ("Data.txt"). GetPath ();File f = NewFile (path);You can't use a relative path, even if it's relative to the SRC directory.

Java Packaging jar and path issues

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.