• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

netbeans directives and compiling to exe

 
Ranch Hand
Posts: 287
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Background:
I'm using netbeans to hopefully turn my java game application into an exe.
My current issue is that I used to jall the jar from a bat file that would set various directives to java and to the program telling it how to behave.
java -jar -Dsun.java2d.noddraw=true AlienSwarm.jar FULLSCREEN
The -Dsun.java2d.noddraw=true part is something I pass to Java and I'm not sure how to do this with the installable exe.
Also the FULLSCREEN option is something that's read by my program but there are a number of similar directives that could be passed.

Is it possible :
  • to pass the -Dsun.java2d.noddraw=true directive when building the exe?
  • to have bat files that can pass different parameters (ie FULLSCREEN MAME etc) to my program?
  • for the installer to ask what params are needed?
  • to have a desktop icon appear?

  • Plus :
  • Why does the app get installed in C:\Users\Mike\AppData\Local\AlienSwarm and not the program files directory?
  • Will the app run OK on 32bit systems as well as 64 bit systems?

  • Sorry for all the questions but I'm very new to netbeans.

    Mike
     
    Saloon Keeper
    Posts: 15529
    364
    • Likes 1
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    I think the easiest way is write your application in such a way that all the options are set in a configuration file, which you can change from an option menu in your application. The user can then specify command line arguments that override the options in the configuration file. This way you only need one batch file that runs the program in the default state. This way you don't need an exe, and your installer can be more platform independent.

    As for a desktop icon, yes you can write an installer that puts a shortcut with an image on your desktop, that points to your batch file. As a matter of fact, you can specify the exact command line parameters in the shortcut, so you don't even need a batch file.

    If you want a more advanced installer, take a look at install4j.
     
    Mich Robinson
    Ranch Hand
    Posts: 287
    2
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Thanks for your quick response Stephan,
    I have to run as an exe as the majority of my users won't have (and don't want Java) on their PC's.
    I think you're right about the using a file - I'll do that.

    Unfortunately I still need to specify the -Dsun.java2d.noddraw=true part when building the exe - is this possible?

    Mike
     
    Stephan van Hulst
    Saloon Keeper
    Posts: 15529
    364
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    If you don't want to use Java, don't use Java. Even if the user doesn't have a system-wide Java installation, you'd still have to bundle your application with a runtime. That is, unless you find a compiler that compiles Java directly to native code. Take a look at the GNU compiler for Java. The FAQ says it does not fully AWT/Swing though. In order to set the system properties from an exe, I think the only reliable way to do it in Windows is to use environment variables.

    In short, your best options are to bundle a JRE with your installer, or just switch to a completely different language.
     
    Marshal
    Posts: 28226
    95
    Eclipse IDE Firefox Browser MySQL Database
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    My brief scan through the web this morning suggested to me that Netbeans now has the ability to produce a Windows EXE directly from a Netbeans project. At least, Mich's original post sort of suggests that's the case. I found some tutorials which appeared to explain how to do that, but they were video tutorials so I didn't look at them. Anyway, it would help to know if we were discussing an actual Netbeans feature or something else. Mich?
     
    Mich Robinson
    Ranch Hand
    Posts: 287
    2
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    Paul Clapham wrote:My brief scan through the web this morning suggested to me that Netbeans now has the ability to produce a Windows EXE directly from a Netbeans project. At least, Mich's original post sort of suggests that's the case. I found some tutorials which appeared to explain how to do that, but they were video tutorials so I didn't look at them. Anyway, it would help to know if we were discussing an actual Netbeans feature or something else. Mich?

    Yes, it's moderately easy producing an exe installer using the current version (7.4) of Netbeans. You need to:
  • Install the latest Netbeans
  • Install Inno 5
  • Install Wix
  • Add Inno 5 and Wix to your path variable (windows)
  • Turn on the native packaging option for your project in netbeans
  • Then package the project as either an msi or exe

  • I also tried launch4J and it worked well however I needed help producing the exe each time which I found frustrating, others might find it's use quite straightforward. Both methods produced an exe of around 30MB which is huge considering the size of the program but I guess small to modern day games. I currently need the Java2d.nodraw=true option to be set because my program plays in a relatively low resolution but using the full screen and without this option I just get a black screen. Others have had the same issue and this is the accepted solution. I may try rewriting the code to see if I can get round the problems I was having.

    I'll admit it's also far beyond my comprehension that java itself doesn't give you the option to create native exe's.
     
    reply
      Bookmark Topic Watch Topic
    • New Topic