How to load file from the Bundle in eclipse & My Eclipse? - eclipse-plugin

This is very strange behavior I have noticed while developing Plugin.
I have a file in the bundle that has to be loaded for wizard.
I tried to load the file in eclipse using following code.
Bundle bundle = Platform.getBundle(MTPAppPlugin.getDefault()
.getBundle().getSymbolicName());
URL fileURL = bundle.getEntry(relativeFilePath);
File file = new File(FileLocator.resolve(fileURL).toURI());
But this didnt worked in MyEclipse.So I used other way for my eclipse
url = new URL("platform:/plugin/"
+ MTPAppPlugin.getDefault().getBundle().getSymbolicName()
+ relativeFilePath);
InputStream inputStream = url.openConnection().getInputStream();
in = new BufferedReader(new InputStreamReader(inputStream));
Now I need to know is there any common way to load the file for eclipse & My Eclipse?

The first one will not work if you have space in your folder path like C:\program files....

The first one seems to be correct. What was the error given in MyEclipse?

Related

How to change this from "../ReportApi" automatically when I deployed?

I've made rdlc reports and view using Syncfusion report viewer and It runs successfully. But, when I deploy it in server then the report could't found. I have to change the path manually from here (the code I've attached)
</script>
<ej-script-manager></ej-script-manager>
In our ASP.NET Core application we are getting the report path from wwwroot folder. So we are using the WebRootPath for getting the wwwroot folder path as shown in below code example. In production side we need to include the report path.
public void OnInitReportOptions(ReportViewerOptions reportOption)
{
string basePath = _hostingEnvironment.WebRootPath;
FileStream inputStream = new FileStream(basePath + #"\ReportData\InvoiceTemplate.rdl", FileMode.Open, FileAccess.Read);
reportOption.ReportModel.Stream = inputStream;
}
Please consult the help documentation for how include the files when publishing the ASP.NET Core application.

Run Groovy Scripts in IntelliJ fails

I can't run or debug Groovy scripts in IntelliJ. I'm getting the error: Error: Could not find or load main class org.codehaus.groovy.tools.GroovyStarter. Running scripts from cmd works propertly (I'm using groovyc and groovy command).
import org.apache.pdfbox.pdmodel.PDDocument
import org.fit.pdfdom.PDFDomTree
import org.w3c.dom.Document
// load the PDF file using PDFBox
PDDocument pdf = PDDocument.load(new java.io.File("file.pdf"))
// create the DOM parser
PDFDomTree parser = new PDFDomTree()
// parse the file and get the DOM Document
Document dom = parser.createDOM(pdf)
I missed https://mvnrepository.com/artifact/org.codehaus.groovy/groovy-all/2.4.12 depedency in my pom.xml file. Bug is resolved. Thanks All for your hints :)
Create Run Configuration (⌘N), and set the Module to the Module that contains all of your dependencies.
I had had the same problem until I did the next:
deleted the groovy from "Global Libraries" (Don't forget to click the 'Apply' button
screenshot how to delete groovy
Opened any groovy file, and click on "Configure Groovy SDK"
screenshot how to select groovy
Selected the folder with groovy installation (see on the screenshot above)
After all, I can run/debug my scripts from IDEA
Try to create you script not as Groovy class.
Use this way:
Ctrl + Shift + A -> Groovy Script -> Set script name

Activator bundle throwing null pointer exception

I am facing a unique problem - the following code block throws NPE only when my plugin is packaged and deployed not when I am launching it as an 'Eclipse Application'
inputStream = Activator.getDefault().getBundle().getEntry(templateFilePath).openStream();
I have tried other variations as well but nothing is working :
inputStream=Platform.getBundle("SuitACore").getEntry(templateFilePath).openStream();
Here templateFilePath is a file resource being read from a directory in plugin.
Thanks Nick , greg-449
I extracted the packaged jar - the template folder resource was not getting included. I changed this option from build.properties and now this works!

How to install php_java extension in wamp?

I have tried this in my php.ini file:
extension=php_java.dll
[java]
java.java = “C:/Program Files (x86)/Java/jdk1.7.0_03/bin/javaw.exe”
java.java_home = “C:/Program Files (x86)/Java/jre7”
java.class.path = “G:/wamp/bin/php/php5.3.9/ext/JavaBridge.jar”
java.library = “C:/Program Files (x86)/Java/jre7/bin/client/jvm.dll”
java.library.path = “G:/wamp/bin/php/php5.3.9/ext;C:/Program Files (x86)/Java/jre7/lib”
Now WAMP shows php_java extention, but php_info() does not shows java configurations.
use phpjavabridge to make communication between PHP and Java.
I have a youtube vid in French on it: https://www.youtube.com/watch?v=pHtgPrFOChQ

Ploblem including a file- Titanium

I get an error while i try to include the js file which is in the same folder. I tried cleaning my project but was of no use.
The console says "error loading path".
Please help.
var db={}
Titanium.include('windows/gallery');
var displayButton= Ti.UI.createButton({
title:'Display',
onClick:function(){
db.gallery.open();
}
});
I have used open function which opens the file. The open file works has no problem.
usually, we use require('files/myFile'), where :
Resources/files/myFile.js is the path (note that require doesn't use the .js)
The js file is NOT at the same level that app.js, but included in Resource folder.
So here, you should do
Titanium.require('windows/gallery');
instead of
Titanium.include('windows/gallery');
By the way, the previous method was Titanium.include('windows/gallery.js');
Note the .js at the end of the include version.
Is it a mobile or desktop version ?