How to read a folder inside resources of oxygen plugin jar
Oxygen general issues.
-
- Posts: 168
- Joined: Fri Feb 28, 2020 4:02 pm
How to read a folder inside resources of oxygen plugin jar
Post by vishwavaranasi »
Hello Team , this might be a general java question , we have a requirement where we have a DB wallet folder inside resources
like oxygen-plugin-project\src\main\resources\Wallet_DB (this folder contains the information to connect to JDBC)
and we tried reading the same folder path inside public void applicationStarted(StandalonePluginWorkspace pluginWorkspaceAccess)
as below
String folderPath=xxxWorkspaceAccessPluginExtension.class.getClassLoader().getResource("Wallet_DB ").getPath();
folderPath=folderPath.replaceAll("file:","");
System.out.println("folderPath" + folderPath);
String DB_URL = "jdbc:oracle:thin:@devdb_medium?TNS_ADMIN="+folderPath;
but the folderPath throwing null pointer exception
like oxygen-plugin-project\src\main\resources\Wallet_DB (this folder contains the information to connect to JDBC)
and we tried reading the same folder path inside public void applicationStarted(StandalonePluginWorkspace pluginWorkspaceAccess)
as below
String folderPath=xxxWorkspaceAccessPluginExtension.class.getClassLoader().getResource("Wallet_DB ").getPath();
folderPath=folderPath.replaceAll("file:","");
System.out.println("folderPath" + folderPath);
String DB_URL = "jdbc:oracle:thin:@devdb_medium?TNS_ADMIN="+folderPath;
but the folderPath throwing null pointer exception
Thanks,
vishwa
vishwa
-
- Posts: 9434
- Joined: Fri Jul 09, 2004 5:18 pm
Re: How to read a folder inside resources of oxygen plugin jar
Hi,
After your add-on is built and deployed in Oxygen, where is the "Wallet_DB" file present inside your add-on? Is it present inside a JAR library? In what folder path is it present inside the JAR library?
Regards,
Radu
After your add-on is built and deployed in Oxygen, where is the "Wallet_DB" file present inside your add-on? Is it present inside a JAR library? In what folder path is it present inside the JAR library?
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
-
- Posts: 168
- Joined: Fri Feb 28, 2020 4:02 pm
Re: How to read a folder inside resources of oxygen plugin jar
Post by vishwavaranasi »
"Wallet_DB" is a folder( which will have all the files like tnsnames.ora and other files required to connect DB)
this folder bundled inside myplugin.jar
C:\Program Files\Oxygen XML Editor 24\plugins\myplugin\lib\myplugin.jar
if i unzip the myplugin.jar
the folder appears at the root of the folder myplugin\Wallet_DB
this folder bundled inside myplugin.jar
C:\Program Files\Oxygen XML Editor 24\plugins\myplugin\lib\myplugin.jar
if i unzip the myplugin.jar
the folder appears at the root of the folder myplugin\Wallet_DB
Thanks,
vishwa
vishwa
-
- Posts: 9434
- Joined: Fri Jul 09, 2004 5:18 pm
Re: How to read a folder inside resources of oxygen plugin jar
Hi,
The Java method "java.lang.ClassLoader.getResource(String)" works only for references to file-like resources.
For example if in the folder "Wallet_DB" you have a file named "marker.txt", you could retrieve the path to it like "ClassLoader.getResource("Wallet_DB/marker.txt")", but it does not work for folder like resources.
https://docs.oracle.com/javase/7/docs/a ... ng.String)
Regards,
Radu
The Java method "java.lang.ClassLoader.getResource(String)" works only for references to file-like resources.
For example if in the folder "Wallet_DB" you have a file named "marker.txt", you could retrieve the path to it like "ClassLoader.getResource("Wallet_DB/marker.txt")", but it does not work for folder like resources.
https://docs.oracle.com/javase/7/docs/a ... ng.String)
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service