I am new to java or coding in general. I am currently taking a course for Computer Programming. For this final assignment I need to make a .jar program or game. I have decided to make a game but it does not execute like it does in an IDE. Thank you in advance for the help.
successful launch in the ide
launch as a .jar file
Thank you for all the help, I have solved my own problem by adding a sleep timer to my gui from the main method and by default setting my gui to invisible, once the main method ran it set the gui to visible. Thank you again for all the help.
Related
I am simply trying to implement a button which will re run a main file in my program. So, essentially when the button is clicked, the application will restart, and it will be like the user is playing the game again from the start. Is this possible? and if so how would I go about coding this button? I am using netbeans IDE 8.0 Thank you all very much for taking the time to try and help me out :) I appreciate it. Kind regards.
Extra Edit 1: Is there anything that will just reopen the main class? I read somewhere that Application.Restart() will work in a C# application. Is there anything like this for NetBeans? Cheers in advance
for restarting application you can use below code
Runtime.getRuntime().exec("java -jar myApp.jar");
System.exit(0);
in netbeans platform application you can use this command
LifecycleManager.getDefault().markForRestart();
LifecycleManager.getDefault().exit();
Surely reading this will help:
http://docs.oracle.com/javase/tutorial/essential/concurrency/runthread.html
You should create a thread where the game is run.
Each time you pressed or reboot or wake up the thread.
I hope it's some help.
When I try to run my applet in NetBeans it tells me that there is no main class. I looked it up and others have had this error, but they don't give great instructions how to fix it. I tried going to Properties > Application > Web Start and changing it to Applet descriptor with my applet class. But, it still doesn't work, and I don't know why. can anyone help me out? Thanks!
Change the run configuration in the toolbar to Web Start:
Now when you click run, it will run the applet.
Try putting in a main class that simply does nothing.
If you have two different classes for this one applet, make sure you are running the one that has a main, only one needs one.
As far as "selecting your applet as the main class" I don't have a clue what that means either.
Hope I've been helpful, I'm new to the whole graphics thing (for java, anyway) too!
If this problem persists, please elaborate!
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.
I'm having this issue in my MATLAB program.
I want to perform a set operation on my UI during a coding. In other words I'm pressing a button to launch my code and at the same time I want to change some uicontrols.
I tried with pause and wait with no luck.
I'm pretty sure that MATLAB gives priority to my coding part intead of the Java interface.
Anyone has any idea? Thanks
Thanks to nick I solved adding
waitnow; pause(.1);
Guys, unbelievable, that works on linux/OSX but not under windows..that's so weird
I am looking into the NetBeans platform for developing desktop applications. I am a complete newbie in it. I understood till now the module architecture. Now I want to do some GUI work. My question is very simple and feel embarrassed to ask it, but how can I edit the main frame of the application? I mean the one generated automatically by NetBeans. I looked around but for god's sake, I can't see it in the IDE:(
Edit: It seems there is a misunderstanding. I know how to create a JFrame:) I am talking about the NetBeans platform, when your application is built on top of the NetBeans core. Here is a short article. At the bottom there are two screenshots. The IDE generates a Main frame looking like the real NetBeans IDE. I can create new modules and so on. But I want to edit this Main frame, but I don't see it in the IDE. Hope my question is clear now.
Thanks in advance:)
Regards,
Petar
As I learned more things of the NetBeans platform, I understood that there is a virtual FileSystem which is build from combining layer.xml files from all modules. This FileSystem is the configuration of the application. It includes things as which menu items to be shown on the main frame, etc. So I guess the main frame is edited this way:)
Yes, is like Petar says, but to be more specific, one way to do this is from the Netbeans GUI is described here. http://platform.netbeans.org/tutorials/70/nbm-htmleditor.html#tweakingthemenuitems. This is for 7.0 version of netbeans.
I found useful this question also How to remove items from menu in netBeans platform?.