So I'm working on a text based RPG as part of my programming class and
I would like my friends to be able to play it without a compiler. Is
there anyway I can put the game in a Dialog box or window so they can
just run it if they have Java?
*Edit: Code Can be provided but I don't think you'll need it as it is just the game fit for running in a compiler.
I think I'm confusing myself and everyone else. I am running the game in my IDE, jGrasp (because that's what we're supposed to use) and in there it will run. Unless I can export it as something else/make it appear as another file I don't know how to let people who don't have jGrasp or Eclipse play it.
Hope that clarifies.
This may be a little bit tricky if you are just starting out with Java, but I will walk you through it.
You will need to first turn your code into a JAR file. Depending on what IDE you are using, this can usually be found in file/export. Then you will need to run the file through a command prompt, such as Terminal.
Locate the jar file you exported, and put it into a easy to find location.
Open terminal and type this into the command prompt: java -jar /Path/to/yourfile.jar
Thats it! It is as if you are running it from your compiler. Just give your friends these instructions, and they will be able to play your game. Enjoy!
If you need something easier to run, look into Swing gui. This will be easier for your friends, but much harder for you.
Related
I have this chess engine i wrote in java. Thing is, I need to make a exe application that can take commands following a certain protocol (UCI). Ive had many problems trying to get this to work, but ill keep this brief and share the most important ones.
Other engines pop up cmd when you click on them, mine is just a basic java CLI (Dont know if this is a problem).
My anti virus keeps stopping me from opening the exe. Launch4j gives me a warning telling me I should sign it to prevent this sort of thing, but I dont know what that means.
So heres the deal, I know this post is word vomit, but Im truly at a loss right now. Id like general order advice on how I should approach the problem and maybe some advice on wether i should be using launch4j in the first place.
UPDATE: The reason i wanted to make an exe in the first place is because thats the format that was suggested in the lichess documentation (I wanted to upload my bot to lichess). I wrote a bat file that executes the jar file and it worked fine. Thanks to everyone for the suggestions.
I am an average ImageJ user who learnt to write IJ.macro and Groovy by trial and error. I did this mainly using the plain a simple script editor within ImageJ. I recently came up with IntelliJ, an amazing IDE with auto-completion and debugger. With the help of google, I was able to include the ImageJ jars, and pluggings accessible as external libraries/modules so that I can use the mentioned functionalities [by adding the path in File>Project Structure>Libraries>"+">Java>... here I selected the folders with the Jars and plugins of ImageJ].
I am, therefore, optimistic that I could achieve the last step. Rather than writing the code in IntelliJ and run with the ImageJ script tool, I was wondering if it could be possible to run a script (say with Groovy or Jython) directly from IntelliJ. Somethin like calling ImageJ when I click run. Maybe changing the Java Run Environment, or using it as VM.
Before finishing, sorry if I am saying something really odd or non-sense. I am an average Joe learning by trying.
Kind regards,
You might want to have a look at this GitHub project:
https://github.com/haesleinhuepf/run_jython_scripts_from_ide
It explains the steps required to run a script from within the IDE by starting up and using ImageJ. The tutorial focuses on Jython, but is applicable to all supported scripting languages.
In general, questions about ImageJ usage and script development are best asked on the Image.sc forum instead of here on StackOverflow.
I've never used ImageJ, but I guess your question is independent of ImageJ :-)
I you use ImageJ from java, you will have a class with a main method. Just right-click on the class and then "run" on the menu which appeared.
After your program has finished, there is a "run"-icon in the upper left corner of the small window which appeared.
I guess that's already close to running a script.
Groovy would be a better starting point for scripting (since it is partly a scripting language). You can code Groovy with the IntelliJ community edition, but for full support you need the ultimate edition. So I guess the groovy console is only available in the ultimate edition...
All other options I am aware of will not give you the auto-completion and only a poor-man's debugger (println)
Hope that helps
I don't know if people still struggle with this, it is now 3.5 years later, but if you start a script with this:
//# ImagePlus myImp
import ij.ImagePlus
ImagePlus myImp = myImp
You can use both the autocomplete of IntelliJ and the SciJava script parameters. I keep the same script file open in both ImageJ and IntelliJ. After a change in IntelliJ, I go to the script editor to run it. It automatically detects something has changed and will ask to update.
This is a bit of a hassle, but I haven't found how to get IntelliJ to execute the script in a running instance of ImageJ.
I'm recently working with Eclipse Che and have the task to import a Java Project that opens a GUI in it (like a simple Swing/SWT Calculator).
I am using the Java CentOS Stack, importing the .jar files, etc. is no problem but I get the "No X11 DISPLAY variable was set, but this program performed an operation which requires it." error.
Obviously, I found many threads about that Error, but I just wanted to ask if it is even possible to open a GUI in a web based IDE like Eclipse Che before wasting hours trying to fix that error when it's not even possible.
Maybe some of you already tried that and have a solution/tip or smth for me.
edit: found a video that answered my question. https://www.youtube.com/watch?v=AjgSp0dkxxU
Thanks anyway.
This will help you out - https://eclipse-che.readme.io/docs/che-and-swing
You need to use the right stack
You need to set the display variable. The way I did this was modify the run command to set it just before the other commands.
The command I used is:
export DISPLAY=:0.0
Also note that this worked for a while for me but randomly stop working a few days back so please tell if you manage to get it working.
I have just completed my first java program. It's sitting in Eclipse pretty as a newborn (which really isn't all that pretty). Anyway, I need to have an icon on the desktop that allows users to click and run the code. I found an example of how to make a .jar from the project in Eclipse, but nothing happens when I click on it. There are a LOT of options in Eclipse so I'm guessing I need to select/deselect something, but the examples online are very few and far between. Since I'm sure I'm not the first person who has done this, I'm assuming I lack the vocabulary to find an answer. Could someone please give me a little direction to find help?
I have tried "compiling" but that's running the code. Anything with .java just tells me how to install Java. There have been too many searches to list them here. Suffice it to say I need a push in the right direction, please.
There isn't realy much to do wrong. Just go to Project -> export and select runnable jar file. Then you just have to pick the right launch configuration and click finish. There is a tutorial with picutres on wikiHow here.
I want to recreate a basic Windows installer, like the ones nullsoft or innosetup produce, but in Java.
Unfortunatly, I'm a bit lost for some points.
First of all I'd have to copy the software data to Program Files, this point seems clear to me. But I suppose that I would also have to send some information to the OS, for instance to have my program's uninstaller listed in the Programs and Features part of the Control Panel.
And I also need to create some icons on the desktop and put an entry on start menu.
There are probably a ton of other things I forgot, so what are they, and what is the best way to do these in java ?
Take a look at IzPack, I think is what you are looking for ...
If you don't like it as it is, you can take a look at the source code at the official git repo.