I have the following line in my Java app, and it's causing the following error message :
WebBrowser webBrowser=new WebBrowser();
org.jdesktop.jdic.init.JdicInitException: java.io.IOException: The filename, directory name, or volume label syntax is incorrect
at org.jdesktop.jdic.init.JdicManager.initBrowserNative(Unknown Source)
at org.jdesktop.jdic.browser.WebBrowser.<clinit>(Unknown Source)
The app still works, but I wonder if there is a way to correct the error ?
There's a problem initializing jdic's native browser but it isn't obvious what it is.
Does passing a URL to the constructor help?
URL url = new URL("http://www.stackoverflow.com");
WebBrowser webBrowser = new WebBrowser();
One more thing to check - do you have a default browser? If so, when you double click on an html file in a file manager does the browser window open? If this doesn't work then perhaps jdic is complaining about your default browser path.
Related
I am using SWT 3.7 to create an RCP application. Windows is my OS and IE is set as the default SWT browser. I want to change the default browser from IE to Mozilla. I've read a few articles and learned that by adding arguments to the eclipse.ini file (-Dorg.eclipse.swt.browser.DefaultType=mozilla) one can set the default SWT browser.
But after adding it to vm arguments (because when adding to the .ini file it is not doing anything), I get the error below:
org.eclipse.swt.SWTError: No more handles [Could not detect registered XULRunner to use]
at org.eclipse.swt.SWT.error(SWT.java:4308)
at org.eclipse.swt.browser.Mozilla.create(Mozilla.java:683)
at org.eclipse.swt.browser.Browser.<init>(Browser.java:99)
The code is breaking on line:
Browser browser = new Browser(parent, SWT.None);
I have already downloaded xulrunner, ran the register command, checked in registry (it's there), added -Dorg.eclipse.swt.browser.XULRunnerPath="C://Program Files (x86)//Mozilla XULRunner//1.9.1//xulrunner" to vmargs but I still get the same error.
Can anyone help me on this issue?
Found this in the eclipse forum:
"Found the problem. I needed to do xulrunner --register-global as administrator. Since there is no difference in the xulrunner output, the only way to tell if the registration occurred is to look in HKLM\SOFTWARE\Wow6432Node\mozilla.org\GRE"
http://www.eclipse.org/forums/index.php/mv/msg/199032/#msg_634819
I have an app that runs fine when I am not attempting to use it as a web start app, but when I convert it to one in Netbeans, it goes belly up. The console is showing a null pointer exception when trying to get a resource that is located in a dependent library. The line of code itself grabs a .png file in that library file and uses it for the window icon. The lines of code that kill it is:
java.net.URL url = ClassLoader.getSystemResource("/com/my/icon/someimage.png");
Toolkit kit = Toolkit.getDefaultToolkit();
Image img = kit.createImage(url); // fails with null pointer exception
If I am not trying to do this as a web start app then I have zero issues. It runs perfectly. Web start = failboat. The code is signed, if that makes any difference. The library file that is being used is one large jar that contains 3 library files I created plus 4 others that are needed which I did not code myself. Do I need to sign the library file as well? Is this possibly an issue in and of itself?
EDIT:
If I take out those lines of code, the web app runs without any issues.
Here is the error:
Exception in thread "AWT-EventQueue-2" java.lang.NullPointerException
at sun.net.util.URLUtil.getConnectPermission(Unknown Source)
at sun.awt.SunToolkit.checkPermissions(Unknown Source)
at sun.awt.SunToolkit.createImage(Unknown Source)
at DDSC.initComponents(DDSC.java:265)
at DDSC.<init>(DDSC.java:103)
Try using getClassLoader().getResource() with just the filename.
Full path isn't required and getClassLoader() handles the magic via WebStart & also locally:
String filename = "someimage.png";
Image resultImg = null;
URL url = getClassLoader().getResource(filename);
if (url != null)
resultImg = Toolkit.getDefaultToolkit().getImage(url);
I got some errors in my app. The app is using applet for accessing local file system.
converting file, for example.
First: Using relative path.
I can place project folder wherever I need and the application still working properly. However, when I placed it on the tomcat server directory, it cannot find the files' path.
Run with browser: file:///C:/report-param/index.html, ok
Run with browser: localhost:8080/report-param/index.html, error
Second: Using absolute path.
The application working well in both browser and tomcat server.
Run with browser: file:///C:/report-param/index.html, ok
Run with browser: localhost:8080/report-param/index.html, ok
Here is my sample code:
File jrxmlPath = new File("reports//people-report-withparam-multi.jrxml");
File pdfPath = new File("reports//people-report-withparam-multi.pdf");
String sourceJrxml = jrxmlPath.getPath();
String destPdf = pdfPath.getPath();
JasperReport jasperReport = JasperCompileManager.compileReport(sourceJrxml);
JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, paramMap,
getPostgreSQLDataSource(driverUrl, username, password));
JasperExportManager.exportReportToPdfFile(jasperPrint,destPdf);
What is the matter on here? Any ideas?
How can I fix the error above? Please help...
Note: if you don't understand, feel free to ask me...
I am trying to open the pdf file which has an image, so I want to display pdf file in AWT window, openPdfFile method and other methods which are provided for opening the pdf file like openPdfFileFromURL, openPdfFileFromInputStream are used from jpedal_lgpl.jar file.
It's working fine in windows, After I deploy the class file in linux server it throwing the following exception:
Exception:at org.jpedal.PdfDecoder.openPdfFile(Unknown Source)
at org.jpedal.PdfDecoder.openPdfFileFromURL(Unknown Source)
please tell me jpedal_lgpl.jar is the supported jar or not.
Is the URL valid/working? Does it open from a browser?
Could anyone please help me out with the following?
I'm trying to insert an image to the blob column in mysql database through a servlet.
I'm selecting the image through the "HTML FILE INPUT TYPE" which is in a JSP file.So the full path of the image is selected.
The error I have been getting is:
HTTP Status 500 - Desert.jpg (The system cannot find the file specified)
type Exception report
message Desert.jpg (The system cannot find the file specified)
description The server encountered an internal error (Desert.jpg (The system cannot find the file specified)) that prevented it from fulfilling this request.
exception
java.io.FileNotFoundException: Desert.jpg (The system cannot find the file specified)
java.io.FileInputStream.open(Native Method)
java.io.FileInputStream.<init>(Unknown Source)
Image.ImgInsert.doGet(ImgInsert.java:51)
javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
note The full stack trace of the root cause is available in the Apache Tomcat/7.0.28 logs.
Apache Tomcat/7.0.28
Where "Desert.jpg" is the image which is on my desktop.
This same program works on my friends computer.
Here is the servlet code:
String s_id = request.getParameter("myid");
int id = Integer.parseInt(s_id);
//IMAGE ACQUIRED FROM THE FROM THE JSP PAGE
String img = request.getParameter("myimg");
File f = new File(img);
FileInputStream fis = new FileInputStream(f);
String query="insert into images.imageinsert(id,image) values(?,?)";
try
{
PreparedStatement pStatement = conn.prepareStatement(query);
pStatement.setInt(1, id);
pStatement.setBinaryStream(2, fis);
int result = pStatement.executeUpdate();
if(result != 0)
{
response.sendRedirect("ImageHome.html");
}
pStatement.close();
Could anyone please help me out?
There are at least two serious conceptual mistakes here.
You seem to think that having the client side local disk file system path is sufficient to obtain the entire file contents in the server side. This is impossible as the client and server don't share the same disk file system (unless they both happen to run on physically the same computer, which of course don't occur in real world).
You're relying on relative paths in java.io stuff. It becomes relative to the so-called "Current Working Directory" which is the folder which is been opened at exactly that moment the webserver was started. This is definitely not the folder where the webapplication is directly sitting in. This is for example C:\path\to\tomcat\bin. The uploaded file surely isn't magically been placed in there.
As to why it works on the machine of your "friend", that's undoubteldly because he's using Internet Explorer which has a security bug wherein the full file path instead of only the file name is been sent as request parameter on an <input type="file"> field of a <form> without enctype="multipart/form-data". Again, as answered, this approach surely won't work in a real production environment.
Your concrete problem can be understood and solved by carefully reading the following answers.
How to get the file path from HTML input form in Firefox 3
getResourceAsStream() vs FileInputStream
How to upload files to server using JSP/Servlet?