10 Replies - 3888 Views - Last Post: 01 January 2013 - 05:24 PM Rate Topic: -----

#1 gfcf14  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 90
  • Joined: 19-January 11

Java webstart: jnlp file not quite calling JAR as desired

Posted 31 December 2012 - 05:22 PM

Hi dreamincode! I've been making a simple program in Java using JMonkey (which is pretty much like NetBeans), and plan to put it up on y site, http://www.gfcf14greendream.com/ . The thing is, I'm not too happy with giving away JARS, so I made the project into a webstart and uploaded both the JAR and JNLP files using FileZilla (of course the webstart was set up so that an instance of the jnlp file calls the jar from my site). I download the JNLP and run it, and it calls the JAR properly, but I've noticed that it only happens when the JAR's permissions are "Read". Meaning that anyone could download it, which I would not prefer. Is there any way to set up the JNLP to call the JAR, but ONLY from there, so that no one who knows/learns the address of it online can download it? If I just remove reading privileges on the jar, I get this, while running the JNLP:

java.io.IOException: Server returned HTTP response code: 403 for URL: http://www.gfcf14greendream.com/...


And I've noticed that I'm unable to save/overwrite a txt file with FileReader. As I try it reading the JAR from my site, I get this:

java.security.AccessControlException: access denied ("java.io.FilePermission" "applications.txt" "write")


I'm guessing both problems are similar, but in any case. Is there a way to save such txt file to the address from where the downloaded JNLP is called? Say if the JNLP is at C:/Users/anuser/Downloads , then the text file would be saved to that address, is that possible? I could always warn that the saved files would be saved to a folder in C:/ , but can this actually be done? And how would I be able to change the JNLP file's name, so that it doesn't just say launch? Any help for any of these questions is greatly appreciated. I hope everyone has a happy New Year!!

Is This A Good Question/Topic? 0
  • +

Replies To: Java webstart: jnlp file not quite calling JAR as desired

#2 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8324
  • View blog
  • Posts: 31,857
  • Joined: 06-March 08

Re: Java webstart: jnlp file not quite calling JAR as desired

Posted 31 December 2012 - 07:10 PM

You haven't poost enough code to diagnose a full diagnostic but seems that your problem is that a JApplet cannot access the local file system
Was This Post Helpful? 0
  • +
  • -

#3 g00se  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2656
  • View blog
  • Posts: 11,197
  • Joined: 20-September 08

Re: Java webstart: jnlp file not quite calling JAR as desired

Posted 01 January 2013 - 04:29 AM

Quote

Meaning that anyone could download it, which I would not prefer.
If they can't download it, they can't run it. It's that simple. The jar runs on the client
Was This Post Helpful? 0
  • +
  • -

#4 gfcf14  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 90
  • Joined: 19-January 11

Re: Java webstart: jnlp file not quite calling JAR as desired

Posted 01 January 2013 - 09:28 AM

Ok, gotcha. If the jar HAS to be readable then I can't win there. I could make a jar public when it comes to applications, but if I wished to make games in java they would either have to run on the site or be distributable in an unreadable format. I've been able to build a fat-jar from a java project, and convert it to an EXE using Jar2Exe. The problem is that such jars are EXTRACTABLE, with WinRar and Izarc. So I rephrase, how would you distribute a jar or any executable java file without the code being easily seen? I never tried obfuscating but it seems it would do more harm than good. Am I wrong?
Was This Post Helpful? 0
  • +
  • -

#5 g00se  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2656
  • View blog
  • Posts: 11,197
  • Joined: 20-September 08

Re: Java webstart: jnlp file not quite calling JAR as desired

Posted 01 January 2013 - 09:51 AM

Quote

I never tried obfuscating but it seems it would do more harm than good. Am I wrong?

It shouldn't do much harm, but bear in mind you can't even then prevent your code being reverse-engineered by the determined. All you can do is make it harder

This post has been edited by g00se: 01 January 2013 - 09:52 AM

Was This Post Helpful? 0
  • +
  • -

#6 gfcf14  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 90
  • Joined: 19-January 11

Re: Java webstart: jnlp file not quite calling JAR as desired

Posted 01 January 2013 - 10:45 AM

But what do you think about distributing an exe?
Was This Post Helpful? 0
  • +
  • -

#7 g00se  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2656
  • View blog
  • Posts: 11,197
  • Joined: 20-September 08

Re: Java webstart: jnlp file not quite calling JAR as desired

Posted 01 January 2013 - 11:12 AM

An exe will make it harder, as long as it doesn't simply wrap normal java binaries. Still not as good as server-side code
Was This Post Helpful? 1
  • +
  • -

#8 gfcf14  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 90
  • Joined: 19-January 11

Re: Java webstart: jnlp file not quite calling JAR as desired

Posted 01 January 2013 - 12:01 PM

Upon running the converted exe, it seems to call the jar from inside without modifying the code, because as the jar starts, the java icon is displayed at the top left, even when the program is minimized. I'm considering it because jar decompilers are easily available online while an exe might still pass as undecompressable, and a programmer who decompresses it might either be too 'new' to understand or not benefit much from it. Although this reasoning would still apply to jars alone, do you still think distributing jars would be a better choice?

In any case, how do java game companies do it to make games without giving away code?
Was This Post Helpful? 0
  • +
  • -

#9 smohd  Icon User is offline

  • Critical Section
  • member icon


Reputation: 1817
  • View blog
  • Posts: 4,625
  • Joined: 14-March 10

Re: Java webstart: jnlp file not quite calling JAR as desired

Posted 01 January 2013 - 12:59 PM

I dont know if I am following here, but when creating jar files, you can decide to remove all source code(.java) and remain with only .class files. This doesnt mean they cant be reverse engineered, but atleast not easily seen by your users.
Is this what you are talking about or you are asking about some advanced protections?
Was This Post Helpful? 1
  • +
  • -

#10 g00se  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2656
  • View blog
  • Posts: 11,197
  • Joined: 20-September 08

Re: Java webstart: jnlp file not quite calling JAR as desired

Posted 01 January 2013 - 03:34 PM

afaik, most of the exe converters simply wrap the java binaries. The purpose of these converters is actually supposedly to make it easier to run the code and not to obfuscate it. I don't know how games distributors do things, but there are no magic solutions
Was This Post Helpful? 0
  • +
  • -

#11 gfcf14  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 90
  • Joined: 19-January 11

Re: Java webstart: jnlp file not quite calling JAR as desired

Posted 01 January 2013 - 05:24 PM

I guess I shouldn't make such a fuss about giving away my code if I get it all through these forums and tutorials online, so I'm just gonna distribute it. But I'm gonna do it as exe, since distributing a fatjar actually disrupts the path to which a program saves files and reads them (and if I didn't distribute a fatjar and instead chose to distribute the jar created through the IDE, I'd be distributing everything separately which could be a bit messy). By the way, I got confused. The program I used to convert the fatjar to exe is not Jar2Exe, it's Executor, in case anyone would wanna try it http://download.cnet...4-10162784.html It's actually pretty handy because it successfully converted the first game I made, which used dispose() and new JFrame() a lot (I was such a rookie), while the other program I mentioned and several others couldn't. Thank you for your help!!

@smohd: do YOU know of any unmentioned advanced code protection?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1