Our In-House Java application launches various http URLs at various times, including URLs to web-pages, MS Word documents, MS Excel documents, PDF files etc.
On over 50+ machines the URL launching works fine and the correct application opens the given page/document correctly. However, on one pesky machine Adobe Acrobat is attempting to open every URL (regardless of whether the target is a pdf or not), and failing (even on pdf documents) with:
There was an error opening this document. The filename, directory name, or volume label syntax is incorrect.
The code to launch the URLs is:
URL url = new URL("http://www.example.com");
BasicService bs = (BasicService)ServiceManager.lookup("javax.jnlp.BasicService");
boolean worked = bs.showDocument(url);
The worked variable is true after the call.
Other points that may be helpful:
The application runs within Java Web-Start.
An applet running on the same machine is able to open URLs correctly using AppletContext.showDocument()
Entering a URL into the Windows "Run..." dialog launches the URL correctly.
We've reinstalled both the JRE and Adobe Acrobat.
Thanks in advance for any advice/help you can offer.
Update:
The following debug code produces the following output:
String[] services = ServiceManager.getServiceNames();
if(services!=null) {
for(int i=0;i<services.length;i++) {
System.out.println("Available Service: "+services[i]);
}
}
BasicService bs = (BasicService)ServiceManager.lookup("javax.jnlp.BasicService");
System.out.println(url);
System.out.println(bs);
System.out.println("bs.getCodeBase():"+bs.getCodeBase());
System.out.println("bs.isOffline():"+bs.isOffline());
System.out.println("bs.isWebBrowserSupported():"+bs.isWebBrowserSupported());
boolean worked = bs.showDocument(url);
System.out.println("bs.showDocument:"+worked);
} catch(UnavailableServiceException ue) {
System.out.println("UnavailableServiceException thrown");
ue.printStackTrace();
}
Available Service: javax.jnlp.BasicService
Available Service: javax.jnlp.FileOpenService
Available Service: javax.jnlp.FileSaveService
Available Service: javax.jnlp.DownloadService
Available Service: javax.jnlp.ClipboardService
Available Service: javax.jnlp.PersistenceService
Available Service: javax.jnlp.PrintService
Available Service: javax.jnlp.ExtendedService
Available Service: javax.jnlp.SingleInstanceService
http://<snip>
com.sun.jnlp.BasicServiceImpl#bbb8b5
bs.getCodeBase():http://xxx.xxxxxx.com:8080/
bs.isOffline():false
bs.isWebBrowserSupported():true
bs.showDocument:true
Have you solved this problem yet? If not, could you try the following?
FileOpenService fos = (FileOpenService)ServiceManager.lookup("javax.jnlp.FileOpenService");
Related
I want my Android app to execute a complex website on a local http server directly on the phone.
For that, I implemented nanohttpd. With this library, I can run locally on my phone on a http server some simple html code like this:
public Response serve(IHTTPSession session) {
String msg = "<html><body><h1>Hello server</h1>\n";
Map<String, String> parms = session.getParms();
if (parms.get("username") == null) {
msg += "<form action='?' method='get'>\n <p>Your name: <input type='text' name='username'></p>\n" + "</form>\n";
} else {
msg += "<p>Hello, " + parms.get("username") + "!</p>";
}
return newFixedLengthResponse( msg + "</body></html>\n" );
}
Similar code can be see in the demo app here.
But what I want is to run a full complex website with an index.html file and many other files (namely javascript files). To be more specific, I want to run a WebGL website on a local server on my Android phone.
So, I have all the files of my website in the 'assets' folder of my apk. When the app launches, I copy all the files to the internal storage of the Android phone (to file:///storage/emulated/0/android/data/com.example.mysuperapp/files )
Thus, index.html is located in /files.
How can I do if I want that http://192.168.0.26:8080/index.html runs smoothly the website located at file:///storage/emulated/0/android/data/com.example.mysuperapp/files/index.html ? (meaning that all the javascript files, imports, etc... should work properly)
If nanohttpd is not designed for that, is there any other tool to do that?
Thanks a lot for your help.
Is there an option how to open a link using only console so for instance, If I enter 1 it will open a separate window where it will open my web link? I mean I want to use external links (URLs) where when I press 1 a chrome window will open with my URL. Is that possible and if so how, because I have only seen people do it using Java Swing. Any help would be great :)
Ok so I tried and this worked:
try {
Desktop desktop = java.awt.Desktop.getDesktop();
URI oURL = new URI("http://www.google.com");
desktop.browse(oURL);
} catch (Exception e) {
e.printStackTrace();
}
You will also need to implement URI and java.awt library
Your question is not clear enough to me, but what I understood is that you want to open the website link from the browser console, if that's what you mean you can do it using this javascript code
For external URLs :
window.location = 'http (s): // www.example.com'
and for the internal URLs :
__ window.location = '/ file.php'
or window.location = '/ file.html'
or window.location = '/ your_route'
As I understand your description you want to open a web link based on an input (1 in your case) in your Java console app. You can use the method exec as the follownig:
try {
Runtime.getRuntime().exec("explorer https://www.google.com");
} catch(Exception e) {
e.printStackTrace();
}
here the exec method calls a command which here I call Google Chrome to open Google.com.
Using this in Windows will open the default browser showing the website.
I have a system that has Windows COM interface so that external applications can connect to it and it has following details
Interface: InterfaceName
Flags: (1234) Dual OleAutomation Dispatchable
GUID: {ABCDEFG-ABCD-1234-ABCD-ABCDE1234}
I'd like to connect to this interface through Java Spring Application, it will sends a request to this interface and process the response.
I've tried to use the following code
ActiveXComponent mf = new ActiveXComponent("ApplicationName.InterfaceName");
try {
Dispatch f2 = mf.QueryInterface(" {ABCDEFG-ABCD-1234-ABCD-ABCDE1234} ");
Dispatch.put(f2, 201, new Variant("Request String"));
} catch (Exception e) {
e.printStackTrace();
}
The executable file opens but it doesn't do what I want. I want to do the following.
How do I make sure, my interface has bee registered, I can see it
under
Computer\HKEY_CLASSES_ROOT\ApplicationName.InterfaceName
Using ActiveXComponent opens the instance of application, which is not required. Application is already running.
call the interface with dispid.
Retreive the response from the call/put/invoke ( which suits best
for my requiremet ? ) and process the response.
I'm working first time with JAVA-COM_Interface and don't have much experience with it also I could find very few examples on the internet for it and I tried to convert the example I found for my project, also I am not sure the approach I am taking to call the interface is correct or not I would be glad if you can give a hand!
I have resolved this using JACOB lib.
1) Download JACOB folder from here.
2) Check your application is working & has details under
Computer\HKEY_CLASSES_ROOT\ApplicationName.InterfaceName
3) Make sure ApplicationName.dll file is registered. If not use this link for more info
regsvr32
4) Use this Java Code to send data to COM Interface with below simple code.
Dispatch dispatch = new Dispatch("Application.InterfaceName");
Variant response = Dispatch.call(dispatch, <DISPID>, message);
syso(response.getString()); // to print the response
Hope this helps.
When I run the following Java code on a Lotus Domino server, I get different results depending on where the code runs.
private void doViewStuff(Session session, PrintStream out) throws NotesException {
Database db = session.getDatabase(null, "myDatabase.nsf");
View view = db.getView("myViewName");
Document doc = view.getFirstDocument();
while (doc != null) {
out.println("doc: " + doc.getUniversalID());
doc = view.getNextDocument(doc);
}
ViewEntryCollection entries = view.getAllEntries();
ViewEntry entry = entries.getFirstEntry();
while (entry != null) {
System.out.println("entry: " + entry.getColumnValues());
entry = entries.getNextEntry(entry);
}
}
When I run the code on the server as a Java agent, there are 37235 documents in the view.
When I run the code in a standalone client, there are only 37217 documents in the view, and the code is much, much slower.
Details and execution environment:
The server version is 8.5.3, the NCSO.jar I used for the client has SHA-1 d879f8992aae49a06769a564217633a9e0fbd1b6.
The database myDatabase.nsf contains about 150000 documents, each with a file attachment.
The missing documents do not appear in a block, they appear between index 10000 and 20000.
In both cases the code runs as the same user account.
What might be the reason that 18 of the documents cannot be found?
Update and Clarification
Upon further inspection, it turned out that I had indeed run the code with different user accounts, and that the inaccessible document had some Reader Names fields.
On the server I had this configuration, although I configured the agent to "Run on behalf of" CN=User Name/O=domain. It didn't matter whether I ran the agent from the Domino Console or via HTTP:
effectiveUserName=CN=User Name/O=domain
commonUserName=domino01
userName=CN=domino01/O=domain
On the client I had this configuration:
effectiveUserName=[NotesException: Not implemented]
commonUserName=User Name
userName=User Name/O=domain
And that was even though I used this code in the client:
Session session = NotesFactory.createSession("127.0.0.1", "User Name", "password");
You say that in both cases the code runs as the same user account, so I want to trust that this is true. I presume, therefore, that you have ruled out Reader Names fields as cause of the discrepancy.
In that case, have you checked the IsValid() property of the ViewEntry objects when you process them in the agent running on the server? Perhaps the NCSO.jar implementation that you are using for the client-side code is filtering out the objects where IsValid() would return false.
I have a desktop application built with jdk 6 which publishes web services to be consumed by a web application. So far I've had no problem while both applications are running in the same physical computer, i can access the wsdl without any problem and the web application works with the desktop application just fine. The thing is I cannot access to the services from a remote computer in the same network. The two PCs are connected and can interact. If I run both applications in PC1, from PC2 I can use the webapp through
http://PC1:8080
I am currently publishing like this:
public Publicador(){
servicios= new Servicios();
Endpoint endpoint = Endpoint.publish("http://PC1:8686/servicios", servicios);
}
where PC1 is the name of the pc. From PC1, i can see the generated wsdl from the following address, and it's the one I used for the wsimport command:
http://PC1:8686/servicios?wsdl
But I cannnot from PC2.
Any ideas why it is not visible from outside PC1?
Incredible as it may seem, I found the simplest of answers... Instead of publishing as
Endpoint endpoint = Endpoint.publish("http://PC1:8686/servicios", servicios);
I published as
Endpoint endpoint = Endpoint.publish("http://0.0.0.0:8686/servicios", servicios);
and that solved it...
Another solution was to get the address to publish from a file, that worked too. I don't know why it didn't hardcoded... I ended up doing it like this:
Properties prop = new Properties();
InputStream is = null;
String currenDir = System.getProperty("user.dir");
String nombreArchivo = currenDir + File.separator + "ubicacion.PROPERTIES";
try {
is=new FileInputStream(nombreArchivo);
prop.load(is);
} catch(IOException ioe) {}
String pc = prop.getProperty("ServiciosWeb");
Endpoint endpoint = Endpoint.publish( pc, servicios);
}