Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Running Java applications on Windows platforms

Options
  • 26-08-2014 4:38pm
    #1
    Closed Accounts Posts: 8,657 ✭✭✭


    Hi there,

    There are a couple of programs that I want to write to quicken up some mundane tasks for users... These programs will need to:

    1. Run on Windows XP / Windows Vista / Windows 7
    2. Be a self contained executable that will not need any other software pre-installed to run.

    I would really like to do this in Java, as I am very familiar with it, but I did have difficulty before when trying to create a self contained executable file so I'm not sure if it's possible. I would appreciate any advice that you programming heads can give me.

    $thank $you;-)


Comments

  • Moderators, Computer Games Moderators, Technology & Internet Moderators Posts: 19,240 Mod ✭✭✭✭L.Jenkins


    You can use BlueJ as a development tool and allows the developer to create an executable Jar file as opposed to an exe.

    http://www.bluej.org/

    Would you not expand your skills to C#? Similar language and builds an exe automatically upon compilation.


  • Closed Accounts Posts: 8,657 ✭✭✭CountyHurler


    Itzy wrote: »
    Would you not expand your skills to C#? Similar language and builds an exe automatically upon compilation.

    Hi Itzy, I spent a lot of time learning Java, even though I havent really had much practical use for it (as most of my jobs have been in networking). So I wanted to try and get some use out of it... However, I never use it for anything object oriented, most of the things I need to do would be file copies, ip address changes etc etc.. practical stuff.

    But even when I went to use Java to change an IP address there was no method for doing this. I had to get it to execute netsh.exe from the command prompt! So I havent ruled out changing language by any means.


  • Moderators, Computer Games Moderators, Technology & Internet Moderators Posts: 19,240 Mod ✭✭✭✭L.Jenkins


    http://msdn.microsoft.com/en-us/library/d11h6832(v=vs.71).aspx

    The above is C# API. If you want to do things through DOS with Java, you can have a look at a Sample of Code here: http://stackoverflow.com/questions/16452964/how-do-i-execute-dos-commands-in-java

    Here is some API in C# for dealing with IP Addresses in C#.


  • Moderators, Computer Games Moderators, Technology & Internet Moderators Posts: 19,240 Mod ✭✭✭✭L.Jenkins




  • Registered Users Posts: 1,731 ✭✭✭GreenWolfe


    Hi Itzy, I spent a lot of time learning Java, even though I havent really had much practical use for it (as most of my jobs have been in networking). So I wanted to try and get some use out of it... However, I never use it for anything object oriented, most of the things I need to do would be file copies, ip address changes etc etc.. practical stuff.

    OP, why aren't you using a scripting language instead? In general, they're more suitable for system administration.

    Seeing as you're using Windows, a better choice (in my opinion) would be finding a common version of PowerShell for each Windows version and scripting towards that. XP might make that idea more difficult though.


  • Advertisement
  • Closed Accounts Posts: 8,657 ✭✭✭CountyHurler


    Itzy wrote: »
    Here's a code example of changing an IP with C#

    Yeah I've been going through sample code for a few IP programs and it's all pretty similar. The way the classes are instantiated, creating the GUI with stock widgets/buttons/frames, the formatting of the language... all very similar. I've downloaded MonoDevelop Xamarin (suggested by a tutorial I watched) and I'm gonna give it a whirl.
    GreenWolfe wrote: »
    OP, why aren't you using a scripting language instead? In general, they're more suitable for system administration.

    Yeah I thought about using PowerShell. I'm learning bits of it at the moment with studying for the 70-410. But I'd like be able to create a simple GUI for some of our other engineers to use, and this rules out PowerShell... Also, I dont think PowerShell is installed by default in XP... I'm not a big fan of Visual Basic either, and I had visions of trying to run scripts on the PCs and coming up with issues with AV / Firewall etc.


    Okay, last chance for somebody to talk me out of C# :p ??


  • Registered Users Posts: 4,766 ✭✭✭cython


    Yeah I've been going through sample code for a few IP programs and it's all pretty similar. The way the classes are instantiated, creating the GUI with stock widgets/buttons/frames, the formatting of the language... all very similar. I've downloaded MonoDevelop Xamarin (suggested by a tutorial I watched) and I'm gonna give it a whirl.



    Yeah I thought about using PowerShell. I'm learning bits of it at the moment with studying for the 70-410. But I'd like be able to create a simple GUI for some of our other engineers to use, and this rules out PowerShell... Also, I dont think PowerShell is installed by default in XP... I'm not a big fan of Visual Basic either, and I had visions of trying to run scripts on the PCs and coming up with issues with AV / Firewall etc.


    Okay, last chance for somebody to talk me out of C# :p ??

    I think that's pretty unlikely, to be honest. Java is possibly the worst language you could look to use to do something as platform-specific as network-level config, etc. (especially on Windows, where you don't even have text files available to manipulate for most of it) as it's designed to be cross-platform where possible. At least a .NET language is designed by MS with Windows in mind, so probably deliberately offers better support for what you want to do, as they don't really give a toss about working across platform, just maybe across versions of their own platform.


  • Registered Users Posts: 403 ✭✭counterpointaud


    I've downloaded MonoDevelop Xamarin (suggested by a tutorial I watched) and I'm gonna give it a whirl.

    You are probably better sticking to the free version of Visual Studio for what you are doing. Xamarin is aimed at people who need cross-platform solutions, if you know you will be on Windows, and want to write a similar syntax to Java Visual Studio / C# is what you want.


  • Closed Accounts Posts: 5,482 ✭✭✭Kidchameleon


    Be a self contained executable that will not need any other software pre-installed to run.

    They will need the JVM. Although this comes with most OS's by default, it may need updating from time to time. Jar's are a total bit*h to distribute, they work on one machine and flop on others, I don't know why Sun/Oracle don't do something about it.


  • Moderators, Business & Finance Moderators Posts: 10,254 Mod ✭✭✭✭Jim2007


    Well you could always use PureBasic and just call the Windows API. You can build basic GUIs with it and there is no runtime required. I sometimes use it for writing little utilities.


  • Advertisement
  • Closed Accounts Posts: 2,267 ✭✭✭h57xiucj2z946q


    2. Be a self contained executable that will not need any other software pre-installed to run.
    Okay, last chance for somebody to talk me out of C# :p ??

    Won't C# binaries need the .NET stuff for MSIL and JIT? Granted most Windows will have this included today, but a lot of older OS like XP by default. Some may have outdated versions.

    If you want something to work with bare-bones install of Windows from NT?, 2000, up till 8.1+ you can use C/C++ with pure Win32 API. If you don't have experience with either of these, you need to see whether the effort & learning curve is worth it for what you are trying to achieve as opposed to using solutions that may require some pre-installed runtime stuff.
    They will need the JVM. Although this comes with most OS's by default, it may need updating from time to time. Jar's are a total bit*h to distribute, they work on one machine and flop on others, I don't know why Sun/Oracle don't do something about it.

    Hmm java is platform independent (within reason). I'm not sure what jar's you are talking about, but I haven't really seen problems with java apps and portability. Can you name a few for example that you had trouble with?


  • Registered Users Posts: 7,157 ✭✭✭srsly78


    Even C/C++ needs the appropriate runtime installed :) Sure you might be able to make do without it, but that would mean no STL etc etc - might as well write it in assembly then.

    Yes you can statically link the runtime, but that is bad practice - what if some bug was found in version X? Also would bloat the size of the binary.

    The reality is that most practical software will require some kind of deployment step.


  • Registered Users Posts: 2,426 ✭✭✭ressem


    Using JavaFX as the GUI client libraries, Netbeans as an IDE together with WiX to create the installer.
    A cutdown standalone Java runtime can be included and distributed with your program, but a bit more finnicky than with visual studio when it comes to adding libraries outside what's included by default.

    http://docs.oracle.com/javafx/2/deployment/self-contained-packaging.htm


  • Moderators, Society & Culture Moderators Posts: 17,642 Mod ✭✭✭✭Graham


    most of the things I need to do would be file copies, ip address changes etc etc.. practical stuff.

    Have you considered using plain old batch files? No need to install any runtime on the end machine.


  • Closed Accounts Posts: 8,657 ✭✭✭CountyHurler


    srsly78 wrote: »
    Even C/C++ needs the appropriate runtime installed :) Sure you might be able to make do without it, but that would mean no STL etc etc - might as well write it in assembly then.

    Perfect.. Just googling for Microsoft Visual Assembly now..
    Graham wrote: »
    Have you considered using plain old batch files? No need to install any runtime on the end machine.

    I'd like to have a visual aspect to the program, for inputting basic parameters / displaying information / open+save dialog boxes and the like. Also, from a personal development point of view, I want to become proficient in a useful modern programming language.


  • Closed Accounts Posts: 8,657 ✭✭✭CountyHurler


    I downloaded Microsoft Visual C# and toyed around with creating a new project, and of course programming Hello World.... I'm not a big fan of the "paint by numbers" style of Visual C#, where the workspace spoonfeeds you everything.. Is there any downside to me just using the Xamarin instead of Visual C#?


  • Registered Users Posts: 7,157 ✭✭✭srsly78


    Visual C# is not a language. C# using the .net runtime is what you mean, as opposed to c# using the mono runtime. In both cases you need to install the runtime.

    Also your comment about "paint by numbers" is way off. Yes there are productivity tools available to help build guis quickly, but you don't have to use these. You can do all the gui stuff in pure code if you so wish (without using xaml or whatever).

    Use the official microsoft one, the tools are better. I still don't understand why you don't use java tho... You just point users at the appropriate JRE and tell them to install it, if they can't figure that much out then there is no hope.


  • Closed Accounts Posts: 8,657 ✭✭✭CountyHurler


    srsly78 wrote: »
    Use the official microsoft one, the tools are better. I still don't understand why you don't use java tho... You just point users at the appropriate JRE and tell them to install it, if they can't figure that much out then there is no hope.

    The point is that I plan to bring the program(s) to site and run them on client computers to quickly carry out some tasks. If getting the program to run involves installing extra software, then I would be just better off (and quicker) carrying out the task manually.

    Maybe if you take something like NetScanner, this might help you to understand what I'm looking for. I bring this on my USB disk and if I want to find out what PCs are on the network I simply run Netscanner from the USB.... on anything from Win 2k to Windows 7.. no need for additional downloads.


  • Registered Users Posts: 7,157 ✭✭✭srsly78


    You can just have the JRE in a subdirectory can't you? All of it on a usb stick, not a big deal.

    http://stackoverflow.com/questions/13045719/how-to-deliver-my-java-application-with-a-particular-jre

    Ignore the answer marked correct, since you only care about x86 windows platforms.
    some guy wrote:
    "Here is what I do My jar file is in a dist folder -copy the system jre folder to dist\jre-win-1.7.0_04 -create a .bat file with the following line in it jre-win-1.7.0_04\bin\java.exe -jar MyProgram.jar"


  • Registered Users Posts: 2,426 ✭✭✭ressem


    srsly78 wrote: »
    You can just have the JRE in a subdirectory can't you? All of it on a usb stick, not a big deal.

    http://stackoverflow.com/questions/13045719/how-to-deliver-my-java-application-with-a-particular-jre

    Ignore the answer marked correct, since you only care about x86 windows platforms.

    Yeah, you can, (structure as shown in 6.3.1 Self-Contained Application Structure from http://docs.oracle.com/javafx/2/deployment/self-contained-packaging.htm link above. ) You may need to specify relative paths in the launcher to ensure it doesn't use the system JAVA_HOME and CLASSPATH.

    Just about a few issues above...
    1. you can use powershell to work with windows forms to create a gui.
    http://www.codeproject.com/Articles/103681/A-Quick-Guideline-for-Microsoft-Windows-PowerShe

    2. you can use the free powergui to compile executables from powerscript files (only against framework 3.5 and 4 though.).

    Or to derail the .net guys, Python portable runtime is also a possibility. http://portablepython.com/

    or py2exe for python 2.7 (not python 3)
    http://wiki.wxpython.org/py2exe


  • Advertisement
  • Closed Accounts Posts: 8,657 ✭✭✭CountyHurler


    ressem wrote: »
    Just about a few issues above...
    1. you can use powershell to work with windows forms to create a gui.
    http://www.codeproject.com/Articles/103681/A-Quick-Guideline-for-Microsoft-Windows-PowerShe

    That's seems like it's fairly bespoke... I've gone through thousands of PowerShell commands while studying for the Windows Server 2012 Server exam and I've heard no mention at all of there being a Microsoft Approved Windows Powershell GUI... Powershell also doesnt run on XP.. (possibly does with downloads, but I've been on site and tried typing powershell in the command prompt and XP doesnt understand)

    I appreciate all the time ye guys have given to the debate. My plan for the moment is to work with C# and test out a few simple programs across the operating systems that I will be working with and see how it goes.


Advertisement