Java console program

前端 未结 6 1838
花落未央
花落未央 2021-02-01 15:30

I was wondering how to make a Java console program. I use Eclipse as IDE. Looking for something similar to C#\'s version of a console program.

Tried Google but only foun

6条回答
  •  别那么骄傲
    2021-02-01 16:12

    I would recommend using a variant of Eclipse Java IDE when working with jar development.

    File > New > Java Project
    
    Right Click "src" > New > Package > Name your package pack1.projectname.
    
    Right Click "pack1.projectname" > New > Class > projectname as class name.
    

    Write all the code your heart desires for this project. Java is a very interesting language. Always use packages with your class files, especially when you are sure that you will be importing your own code in other files. So you can do import pack1.projectname.handler.EventHandler;

    File > Export > Java > JAR file, or Runnable JAR file > Next > export destination
    

    This will package your jar file, appropriately with a META-INF manifest, also if you are developing an application or plugin, for anything like Minecraft. You will want a plugin.yml and config.yml file. You right click the project folder not "src" in the project explorer. Do New > File > plugin.yml and config.yml. Just a side note.

    The reason I always use pack1 as my toplevel package identifier is of course so I can tell which pack I am working with as I update my project. I always do this to easily compare files I have updated, why I updated them, etc. etc. So initial distribution would be pack1.projectname. Next version pack2.projectname. Also, when not updating code in an entire file, you can just import pack1.projectname.handler.EventHandler; import pack2.projectname.builder.RandomFile; pack3.projectname.init.init; These is a very organized way to develop in Java using Eclipse.

    Hope this helped you on your quest to beginning your projects in Java. I will not write Java code on stackoverflow unless the person asking shows a snippet of his own project, and just cannot break through his coders block. Practice makes perfect.

提交回复
热议问题