Results 1 to 10 of 10
  1. #1
    Moonshine is offline Member
    Join Date
    Feb 2017
    Posts
    5
    Rep Power
    0

    Default How do I run a Java program in Eclipse?

    I have been given a file called nnx.jar by a friend and when I open it in winrar, I can see it contains a "META INF" folder, an "org" folder, some ".jar" files, a ".class" file, a ".java" file and that's about it.

    He told me that I have to run it in a program called Eclipse if I want it to work, but I can't figure it out.
    Could someone do like a step by step on how to run such a java program in Eclipse?
    Last edited by Moonshine; 02-12-2017 at 11:59 AM.

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    20,001
    Rep Power
    33

    Default Re: How do I run a Java program in Eclipse?

    Moved to Eclipse section.

    Normally a jar file is executed using the java command. Do you have the java JRE installed on your PC? If so, trying to open the jar file by double clicking on it should start its execution.
    To manually execute the jar file, open a command prompt window, change to the folder with the jar file and enter:
    java -jar <THEJARFILENAMEHERE>.jar
    If you don't understand my response, don't ignore it, ask a question.

  3. #3
    asdfg is offline Senior Member
    Join Date
    Nov 2016
    Posts
    163
    Rep Power
    3

    Default Re: How do I run a Java program in Eclipse?

    Is it possible to extract java code from .jar ?

  4. #4
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    20,001
    Rep Power
    33

    Default Re: How do I run a Java program in Eclipse?

    Is it possible to extract java code from .jar ?
    Yes. A jar file can be openned and its contents extracted using a zip utility. For example add .zip to the filename and open it.
    If you don't understand my response, don't ignore it, ask a question.

  5. #5
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    6,226
    Rep Power
    13

    Default Re: How do I run a Java program in Eclipse?

    You can also extract it with the jar program. Uses the same types of commands as Unix based tar.
    Type jar -help for more info. It is included in the JDK.

    Regards,
    Jim
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

  6. #6
    Moonshine is offline Member
    Join Date
    Feb 2017
    Posts
    5
    Rep Power
    0

    Default Re: How do I run a Java program in Eclipse?

    Quote Originally Posted by Norm View Post
    Moved to Eclipse section.

    Normally a jar file is executed using the java command. Do you have the java JRE installed on your PC? If so, trying to open the jar file by double clicking on it should start its execution.
    To manually execute the jar file, open a command prompt window, change to the folder with the jar file and enter:
    java -jar <THEJARFILENAMEHERE>.jar
    So there are no circumstances where a program can work only through Eclipse and not the standard way?

  7. #7
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    20,001
    Rep Power
    33

    Default Re: How do I run a Java program in Eclipse?

    Eclipse is a tool for developing programs. It might be possible to construct a program that will only work in Eclipse. I don't have any idea if that is possible or not, or why anyone would want to do that.
    If you don't understand my response, don't ignore it, ask a question.

  8. #8
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    6,226
    Rep Power
    13

    Default Re: How do I run a Java program in Eclipse?

    Interesting you should bring that up. This post suggests doing just that, imo. https://www.java-forums.org/eclipse/...archy-api.html

    Regards,
    Jim
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

  9. #9
    Moonshine is offline Member
    Join Date
    Feb 2017
    Posts
    5
    Rep Power
    0

    Default Probably the noobiest question on here, but how do I run this .jar file?

    Okay, I like .exe files because you only click on them and they run, and I don't really know what to do here. I have a .jar file and I tried opening with WinRar, but I don't know if I'm on the right track. So I uploaded the file here https://ufile.io/cd86a and I hope that someone could perhaps take a look and instruct me.

    Thanks!

  10. #10
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    20,001
    Rep Power
    33

    Default Re: Probably the noobiest question on here, but how do I run this .jar file?

    If the jar file was properly created and you have a JRE installed, double clicking on the jar file should start the java program it contains to start executing.

    To see if there are errors, open a command prompt window, change directories to the directory with the jar file and enter:
    java -jar THEJARFILENAME.jar

    If there are errors, copy the full contents of the window and paste it here.

    Threads merged.
    Last edited by Norm; 04-07-2017 at 01:14 AM.
    If you don't understand my response, don't ignore it, ask a question.

Similar Threads

  1. Can't run java coding program (eclipse)
    By ZaneLearnsJava in forum Eclipse
    Replies: 1
    Last Post: 03-14-2014, 09:03 AM
  2. Eclipse won't run the java program
    By HelloWorld1234 in forum New To Java
    Replies: 8
    Last Post: 04-03-2013, 07:28 PM
  3. Java program in Eclipse help (Mouse events in applet)
    By M-Dub4321 in forum New To Java
    Replies: 6
    Last Post: 06-11-2012, 04:06 PM
  4. Need help with java program using eclipse
    By starplayerrob in forum New To Java
    Replies: 16
    Last Post: 07-01-2011, 09:34 AM
  5. Running a java program without eclipse / JAR Files?
    By littledrummerboy in forum New To Java
    Replies: 7
    Last Post: 05-30-2011, 06:38 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •