• Log in or sign up for an account here: https://www.sythe.org/login

Help Please

  • Thread starter Thread starter Draucia
  • Start date Start date
D

Draucia

Guest
I coded this Java program that opens with command prompt (no GUI or anything), and to run it, I open cmd and type

"java C:\Users\xxxxxxxxxx\xxx.java".

Is there someway that I can create a file (windows executable would be preferred), when clicked, will open that in cmd (or is there some other way to open it?).

Please help me.
 
<3 n4n0
Discord Verified
Two Factor Authentication User
Community Participant
Spam Forum Participant
Sythe's 10th Anniversary
Sythe Awards 2011 Winner
Open notepad. Paste that in. Save it has "run.bat"...
 
I've worked with java for a while, but I haven't made a executable file. Maybe save it as a .jar? or get a java compiler and maybe this should fix your problems.
 
What error do you get?


Well if I first type: cd [directry of .class file here], then type: java [file name], it works, but if I just type: java c:\users\xxxx\xxxx it doesn't work.
I don't really need an .exe, just some way to open it without typing java then the class file name because other people who don't know much about java won't be able to do that. Do you know how I can get that into a jar file? I click export as a java jar, but it doesn't work when I double click.
Oh and it's a console java application so it opens in command promt.

I've worked with java for a while, but I haven't made a executable file. Maybe save it as a .jar? or get a java compiler and maybe this should fix your problems.

I've tried saving it as a .jar, it doesn't work. And yes, I have a java compiler, thats how I compiled it into a .class file.
 
Well if I first type: cd [directory of .class file here], then type: java [file name], it works, but if I just type: java c:\users\xxxx\xxxx it doesn't work.
I don't really need an .exe, just some way to open it without typing java then the class file name because other people who don't know much about java won't be able to do that. Do you know how I can get that into a jar file? I click export as a java jar, but it doesn't work when I double click.
Oh and it's a console java application so it opens in command promt.
Just type "java NAMEOFJAVAAPPLICATION" in the batch file, and save it in the same directory as your Java file.
 
Just type "java NAMEOFJAVAAPPLICATION" in the batch file, and save it in the same directory as your Java file.

Yeah thanks that worked, but is there some way I can package that into one file like a .jar file or maybe even .exe?
 
Ok, you can do it like a rsps private source. Just read the batch files in those.
And how do you think they do it..?

@OP Why not just import your code into an IDE like Eclipse, or IntelliJ and have that export the jar for you (coding within an IDE really speeds up development time)?
 

I don't really get that. There is one for class, which I have, and there is a option for main class or something. What is that going to be?

Ok, you can do it like a rsps private source. Just read the batch files in those.

Umm.. I don't really get it. o_O

And how do you think they do it..?

@OP Why not just import your code into an IDE like Eclipse, or IntelliJ and have that export the jar for you (coding within an IDE really speeds up development time)?

I made it in Eclipse, and when I export the .jar file and double click it, nothing happens. Did I mention this is a console application that opens in command prompt?

^That is your best bet.

Okay


Thanks for taking the time to help me. :)
 
made it in Eclipse, and when I export the .jar file and double click it, nothing happens. Did I mention this is a console application that opens in command prompt?
Oh, so the problem isn't that it doesn't run (it does run), but you don't see the output because the console isn't visible.

Type:
Code:
@echo off
java -jar JARNAME.jar
pause
And save it as run.bat in the same directory as your .jar file (change JARNAME.jar to the name of your jar, of course). Double click run.bat and it should run with the output visible. Then to update, simply replace the old jar with the new one.

I do recommend, however, giving your application a GUI (Graphical User Interface) so that they can see the output in a nice window instead of in command prompt/terminal.
 
Oh, so the problem isn't that it doesn't run (it does run), but you don't see the output because the console isn't visible.

Type:
Code:
@echo off
java -jar JARNAME.jar
pause
And save it as run.bat in the same directory as your .jar file (change JARNAME.jar to the name of your jar, of course). Double click run.bat and it should run with the output visible. Then to update, simply replace the old jar with the new one.

I do recommend, however, giving your application a GUI (Graphical User Interface) so that they can see the output in a nice window instead of in command prompt/terminal.

Thanks, but isn't there some way I can package it into 1 file that I can send to someone. And also, I do not know how to make a GUI yet, I'm still learning. Or is it not hard and you can tell me now?
 
Thanks, but isn't there some way I can package it into 1 file that I can send to someone. And also, I do not know how to make a GUI yet, I'm still learning. Or is it not hard and you can tell me now?

No. Because you're doing System.out.println()'s to show the user data, you must run it in terminal, so it has to be more then a single file.

As for making a GUI, you should take a look at Sun's Swing Tutorials.
http://java.sun.com/docs/books/tutorial/uiswing/
 
No. Because you're doing System.out.println()'s to show the user data, you must run it in terminal, so it has to be more then a single file.

As for making a GUI, you should take a look at Sun's Swing Tutorials.
http://java.sun.com/docs/books/tutorial/uiswing/


Ok thanks, at least I got it working. I'll look at the tutorials, but I think my PDF tutorial will be better for me.


EDIT: Ugh it says failed to load main class manifest.
 
Ok thanks, at least I got it working. I'll look at the tutorials, but I think my PDF tutorial will be better for me.


EDIT: Ugh it says failed to load main class manifest.

When you're exporting the jar in eclipse, don't press the finish button as quickly as you can, press the next button until the final screen. On that screen, you must select the main class of the jar file (this is the class with your main method which will be called by the JVM to start your program). Once you do that, you can hit finish.
 
When you're exporting the jar in eclipse, don't press the finish button as quickly as you can, press the next button until the final screen. On that screen, you must select the main class of the jar file (this is the class with your main method which will be called by the JVM to start your program). Once you do that, you can hit finish.

The "Next" button is disabled. What should I do?
 
duelarena.gg
Back
Top