I've coded a game in Eclipse (still working on it), is it possible to run it's jar file in browser so that anyone can play right from their browsers instead of downloading jar file?
I.e I upload it on my website so that anyone can play right from the link I provide them.
Consider using Java Web Start with JNLP. You can host a JNLP file on a web server somewhere, along with your jar, and users can use a desktop shortcut pointing to the link, or a browser to open your app. (Using a browser will require having a web page with an applet tag: the article mentions how to do this but doesn't separate the two.)
Related
Is there some way to setup a GWT UpLoad to start browsing from a specific folder ?
To have the windows browser work from a specific folder ?
or is that impossible in which case you would have to use some other way...
Could JAVA WEB START as shown here be limited or start from a specific folder ?
http://docs.oracle.com/javase/tutorial/uiswing/examples/components/JWSFileChooserDemoProject/src/components/JWSFileChooserDemo.java
You won't be able to change the default directory for uploads in a browser from a web page. That's a security issue - see commentary control the working directory for <input type=“file”>?.
Given permission to the local machine, Java applets/applications deployed JWS would have the ability - additionally, ActiveX controls could also work for you if you're focusing on Windows.
I have a set of help files for my SWT application that I have open in-application using the Browser control. Navigation through the help files is done through hyperlinks of relative pathnames (i.e: <a href="aboutUs.htm">, so only one html file is actually opened by java code, helpHome.htm. I am opening this using String homeURL = this.getClass().getResource("/help/helpHome.htm").toString(); and browser.setURL(homeURL); This works beautifully when I'm just debugging it in Eclipse. Unfortunately, when I move the project into a .jar, the browser gives the standard "can't find this webpage" error. I've tried using the browser.setText(String); function as described in this link, which works for helpHome.htm, but when I click a hyperlink, it brings me to a blank page displaying the relative pathname. Is there a way to convince browser to open an html file from an executable jar using the setURL(String) method? If not, are there any suggested workarounds for me to achieve similar results?
Thanks in advance!!
You have to start an internal Server as explained here on any available port on your application start up and make your html files available as static resources to the server.
Then set the browser.setURL(homeURL). All the subsequent hyperlinks will now point to the server, which knows how to serve the requested resources.
The hyperlinks are resolved to File System Path (Ex. file://C:\workspace....) while you are running or debugging your application in eclipse and things were working fine then. But that is not the case when you run your app from a runnable jar.
I have a need to "pop up" operating system folders from my web app, mostly to locate files in them. My users don’t want to use a conventional web upload/download paradigm. I have 7 or 8 static folders that need to be opened in explorer on a PC or in Finder on a mac. These folders are all network available, but are buried, and for convenience need to be shown on a web page.
There are IE tricks to do this, and I've written a sample flash app that only allows the browser to open, but I know most browsers sandbox this, and keep me from calling these folders. I am aware that some Java libraries deal with the opening of folders, does anyone have any thoughts or samples for this?
The only way I can imagine is to create a Signed Java Applet.
Applets cannot access the filesystem (and a lot of other ressources) if they are not valid signed. Maybe you can also grant the permission by a policyfile.
There ist a tutorial at JavaRanch.
But I am not sure, if this solution will be very helpful, because the JavaPlugin will be removed from a lott of browsers in near future. (I think FireFox already removed it).
I think there is actually NO solution to this problem.
There may be some workarrounds:
Put a Batch-File onto the server, which opens the folder, if executed
Can you create a local service, which handles requests from you webpage and opens the folder.
Create a webapplication, which opens the folder at serverside, and create a webpage, which displays the content in you website.
In one of my java console application, I am dynamically creating html page. Now I want to open it using default web browser. So can you guys please help me out to solve it.
Swing java.awt.Desktop.getDesktop().browse(uri);
SWT Program.launch(uri);
Taken from In Eclipse Plug-in, how to launch a web url using system broswer?
Assuming you have a file to open.
You should read Runtime it allows you to execute a launch of a program (your default browser for instance.
With Java, your website is dynamic, so you need a server to run your web application. The most common one is Apache Tomcat. You should read about Tomcat if you plan to program websites with Java.
Recently, I had came across an open source a Java applet. I wanted to know is there somehow I could create a script that could be distributed and the applet could be embedded in any website?
I have been able to inject JQuery and JS scripts into websites by placing a <script> tag pointing to a Javascript file and placing it in the header of the page but I don't know how a java applet can be injected.
You can take a look at corresponding tutorial page: http://download.oracle.com/javase/tutorial/deployment/applet/deployingApplet.html
General steps are the following:
Build applet JAR file
Create a JNLP file, which describes your applet
Create web page, which includes script, which starts applet
Deploy all these artifacts on some web server