How we can open browser through j2me code in ubuntu os? - java

How we can open browser through Java ME code in ubuntu os ?
I am using the below given code
String URL1="any url";
midlet.platformRequest(URL1);
The above line does not open the browser in the UBUNTU 10.10 but its working fine on windows os.
Please help me if any body else have faced the same problem.

if you use emulator (which one?), check if it is properly configured (emulators tend to have stuff like that in User Guide y'know)
eg this article provides a recipe for WTK / ME SDK:
...The J2ME Wireless Toolkit supports the platformRequest() method, but
before using the method you must tell the toolkit what to do when it's
invoked. You can associate only one platform service with
platformRequest(). For instance, if for testing purposes you associate
the method with your browser, the browser will be launched every time
you call platformRequest(). If you need more flexibility, you can
associate platformRequest() with a script that will use the URL
scheme to route the request to the right handler.
To associate a particular platform service with platformRequest(),
simply add a com.sun.midp.midlet.platformRequestCommand attribute to
the system.config file in the toolkit's lib directory. For example, to
invoke the Mozilla browser whenever platformRequest() is called, add
the following to system.config:
# Associate the Mozilla browser with platformRequest() - Windows
com.sun.midp.midlet.platformRequestCommand: "C:\Program Files\mozilla.org\Mozilla\mozilla.exe"
Given this setting, the call
platformRequest("http://developers.sun.com/mobility") will launch
Mozilla, and the browser will navigate to Sun's developer mobility
portal...

Related

Registering a java application as the default browser in Windows 10

I am writing a java application, which can handle standard links (http/https).
How can I register my application as the default program opening these links (aka default browser) in Windows 10?
I know I can select the default browser in the windows settings, but it only shows a limited list, no way to hook up a custom program.
I've found this, but it only shows how to do it pre-win10, plus I'm not sure it can be done in java.
The application needs to be packaged as an exe.
I used launch4j for this. Make sure textVersion and icon is set.
A lot of registry keys need to be created. I've pieced those together by looking at this post (kindly linked by #Tarun Lalwani), this post, and the registry entries created by firefox. This means some of them might not be necessary.
Register client
[HKEY_LOCAL_MACHINE\SOFTWARE\Clients\StartMenuInternet\MyApp\Capabilities]
'ApplicationDescription'='MyApp'
'ApplicationIcon'='C:\MyApp\MyApp.exe,0'
'ApplicationName'='MyApp'
[HKEY_LOCAL_MACHINE\SOFTWARE\Clients\StartMenuInternet\MyApp\Capabilities\URLAssociations]
'http'='MyAppURL'
'https'='MyAppURL'
[HKEY_LOCAL_MACHINE\SOFTWARE\Clients\StartMenuInternet\MyApp\DefaultIcon]
#='C:\MyApp\MyApp.exe,0'
[HKEY_LOCAL_MACHINE\SOFTWARE\Clients\StartMenuInternet\MyApp\shell\open\command]
#='C:\MyApp\MyApp.exe'
Register url handler
[HKEY_LOCAL_MACHINE\Software\Classes\MyAppURL]
#='MyApp Document'
'EditFlags'=0x2
'FriendlyTypeName'='MyApp Document'
'URL Protocol'=''
[HKEY_LOCAL_MACHINE\Software\Classes\MyAppURL\DefaultIcon]
#='C:\MyApp\MyApp.exe,0'
[HKEY_LOCAL_MACHINE\Software\Classes\MyAppURL\shell]
#='open'
[HKEY_LOCAL_MACHINE\Software\Classes\MyAppURL\shell\open\command]
#='"C:\MyApp\MyApp.exe" --url "%1"'
Register to default programs
[HKEY_LOCAL_MACHINE\SOFTWARE\RegisteredApplications]
'MyApp'='Software\Clients\StartMenuInternet\MyApp\Capabilities'
Now the application can be selected in the windows settings

Load chrome extension using java programming

I have create a download manager like IDM and I want to install chrome extension.
As you see when you install IDM it automatically add chrome extension in it.
I want to do it like that whenever mine Downloader install it will automatically add chrome extension same as IDM.
I'm new in software development so, how to do that I'm using java programming.
I checked IDM folder and found .crx file which mean this is chrome extension.
And I think IDM load extension from this folder to chrome.
But according to my search Google disable to install chrome extension out of Chrome web store then how IDM do it.
Any suggestion which things I need to do that ?
UPDATE:
I try to install it using preference JSON but its not working.
I followed a method which is described here.
please check out this link.
After facing a same problem, I found this Google article which will help you to Load Chrome extension from outside.
An extension that is not installed from the Chrome Web Store is known as an external extension. For developers who want to distribute an extension as part of the installation process for other software, or for network admins that want to distribute an extension throughout their organization, Google Chrome supports the following extension installation methods:
Using a preferences JSON file (for Mac OS X and Linux only) Using the
Windows registry (for Windows only) Both ways support installing an
extension hosted at an update_URL. On Windows and Mac, the update_URL
must point to the Chrome Web Store where the extension must be hosted.

Launch an Application from a Browser

I would like to have a link or button on my web site that launches
vim (an editor) on a specific file (e.g., myfile.txt) on my local machine.
I want to launch C:\Vim\Vim74\gvim.exe on C:\Users\paulco\myfile.txt form any browser.
I want this to work on all (realistically most) browsers.
I actively use Chrome, Opera, FireFox and IE (in that order of preference).
In order for it to work across all of these browsers,
I think the script has to Java-based.
Does anyone know how to do this?
Does anyone have a Java-based script that does this?
Here are some resources I found on the topic.
But either they are IE specific or don't work.
Launch application from a browser
http://msdn.microsoft.com/en-us/library/aa767914%28VS.85%29.aspx
I have tested the following on Internet Explorer, Chrome, Opera and Firefox.
The browser has to run on a Windows operating system, Linux and Mac require different aproaches.
Solution is to define a protocol handler for a custom protocol.
1) Take this HTML example, it should open the specified text file using notepad.exe:
Open Textfile
2) You need to define the protocol handler in the windows registry, save the following to a file named testing.reg and execute it (double click on it), or enter the values manually using regedit:
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\test]
#="URL:Editor test"
"URL Protocol"=hex(2):00,00
[HKEY_CLASSES_ROOT\test\DefaultIcon]
#="\"C:\\Windows\\system32\\notepad.exe\""
[HKEY_CLASSES_ROOT\test\shell]
[HKEY_CLASSES_ROOT\test\shell\open]
[HKEY_CLASSES_ROOT\test\shell\open\command]
#="\"C:\\temp\\editor.bat\" %1"
3) As you can see, I am not calling notepad.exe directly, but a c:\temp\editor.bat batch file. This is because the file-parameter has to be modified. using the %1 as a parameter will pass the complete URL including the test: custom protocol name to the shell. In the script, I use a simple substring pattern to extract the specified file name and call the editor:
REM editor.bat
set param=%1
notepad %param:~5%
That's all!

System-level Proxy switcher using Java

Can we use Java (included JNA) to change Windows proxy settings (System level, not just for JVM) on the fly. I found some code snippets for C# where they are using InternetSetOption() API provided by wininte.dll. I've tried but it does not work also. All I want is to change IE and Chrome proxy settings by running a JAR file (desktop app) without restarting the browser.
Thank you so much!

Java: Control browser through Process

I'm remote controlling a Java application on a PC through an Android phone, and I needed my application to open a browser at the phones command, chrome in this case. I created a "Process" for chrome, opening a certain address. However, I need to be able to give tools on the Android phone for controlling the web page, such as scrolling. Can I programmatically send a command for chrome to scroll from my PC application containing the Process?
Sorry, it may have been unclear, but the only connection the android phone has to the program is through a socket. It is only used as a remote control for another Java application on a PC, which has its own screen.
I do not think that clean solution exists.
But I can suggest the following directions:
(1) try to investigate the native chrome API. If it has such ability call it with JNI.
(2) Try to use class java.awt.Robot. It allows to simulate user's activity, e.g. mouse clicks. Unfortunately it does not allow you to find any window outside your application, so it is a problem to decide where to perform the click.
(3) You can create proxy server and make browser you open to go to the target URL through the proxy. The proxy server will insert into the page your javascript that will communicate with server. The application that opens browser will send commands to server. The javascript that you inserted will receive these commands using AJAX and perform them. JavaScript can scroll browser window, so theoretically you can implement this.
If you can target the tab you want to control and edit the address bar you could send the command 'javascript:scrollTo(x, y)'. I just tested it on this page and it seems to work fine, replacing what I typed with the original address of the page.
Can I programmatically send a command for chrome to scroll from my PC
application containing the Process?
Not directly. What you could do is make some sort of web service that sits between the Android client and page that the Android client can send commands to and the page can periodically poll via AJAX calls to see what the client wants. That would be a clean DIY way that would work on other browsers besides Chrome.
You can use vnc viewer applications for that.
http://code.google.com/p/android-vnc-viewer/

Categories