英文:
How do I find the main class in a Java project?
问题
我已从版本控制中下载了一个Java项目 -> git
这是位置:
https://github.com/kjhulin/CryptokCodeCracker
将项目导入IntelliJ IDE。我尝试运行它,但它一直提示我编辑配置并添加一个主类。
我不确定什么是“主类”。谢谢!
英文:
I have downloaded a Java Project from version control -> git
This is the location :
https://github.com/kjhulin/CryptokCodeCracker
Imported the project into IntelliJ IDE. I tried running it, and it kept prompting to edit the configurations and add a main class.
I'm not sure what the main class
is. Thanks!
答案1
得分: 2
Main Class是一个类,其中实现了main()
方法。当您尝试在服务器上使用命令提示符运行JAR文件时,JVM将从这个方法开始程序执行。这个类在MANIFEST.MF
文件中进行搜索,您可以在其中指定Main-class。
当您尝试从eclipse/IntelliJ IDE运行时,您可以选择主类并直接运行。
一个主方法看起来像这样:
public static void main(String[] args)
在您的代码库中,我可以看到这些类实现了主方法:
路径:CryptokCodeCracker/src/rkccrack/
文件: CodeCracker.java
RKCCrack.java
StreamCrack.java
而这是您的Manifest文件条目:
路径:CryptokCodeCracker/Manifest
内容:Main-Class: rkccrack.CodeCracker
英文:
Main Class is the class where you have the main()
method implemented. When you are trying to run a JAR file in a server using command prompt this method will be called from JVM to start the program execution. And this class is searched in MANIFEST.MF
file where you specify the Main-class.
And when you try to run from eclipse/IntelliJ IDE, you can select the main class and try to run directly.
A main method looks like this :
public static void main(String[] args)
In your repository, I could see these classes have the main method implemented :
Path : CryptokCodeCracker/src/rkccrack/
Files : CodeCracker.java
RKCCrack.java
StreamCrack.java
And this is your Manifest file entry :
Path : CryptokCodeCracker/Manifest
Content : Main-Class: rkccrack.CodeCracker
答案2
得分: 0
为了运行Java程序,您需要在系统上安装Java。您可以从这里获取它,并且您需要设置Java环境链接并配置IDE以使用您安装的JDK。为此,请打开Intellij并单击文件>项目结构,那里有一个名为“项目SDK”的选项,您需要指定您安装的JDK的路径。
要运行此代码,您需要导航到CodeCracker.java并单击运行按钮,这里是我的配置的照片,希望这有所帮助。
英文:
in order to run a java program you need to have java installed on your system.you can get it from here and you need to setup java env link and configure the ide to use the jdk you installed, for that open Intellij and click on files>Project Structure there is a option called Project sdk and you need to specify your jdk installed path.
And to Run this code,you need to navigate to the CodeCracker.java and click on run button here is a photo of my config hope this helps
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论