运行HelloWorld.java时找不到java.exe

时间:2018-10-21 16:22:24

标签: java windows cmd

(我是初学者) 我想编译并运行一个名为HelloWorld.java的文件。我安装了最新的jdk,并通过cmd编译了文件。此方法有效,并创建了HelloWorld.class文件。当我尝试命令“ java HelloWorld”时,它说:"C:\ProgramData\Oracle\Java\javapath\java.exe"找不到。当我进入该目录时,可以看到java.exe文件。我还为Java\jdk-11.0.1\bin目录设置了路径变量,但是没有任何作用。

为什么总是说找不到文件?

提到的两个目录都有一个java.exe文件。

1 个答案:

答案 0 :(得分:2)

我知道了: 安装jdk时,将创建以下路径变量:package com.app.clupascu.oavm; import android.os.Bundle; import android.support.annotation.NonNull; import android.support.design.widget.BottomNavigationView; import android.support.v4.app.FragmentTransaction; import android.support.v7.app.AppCompatActivity; import android.view.MenuItem; public class MainPage extends AppCompatActivity { private BottomNavigationView.OnNavigationItemSelectedListener mOnNavigationItemSelectedListener = new BottomNavigationView.OnNavigationItemSelectedListener() { @Override public boolean onNavigationItemSelected(@NonNull MenuItem item) { switch (item.getItemId()) { case R.id.navigation_home: setTitle("Map"); FirstFragment fragment = new FirstFragment(); FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction(); fragmentTransaction.replace(R.id.fram, fragment); fragmentTransaction.commit(); return true; case R.id.navigation_dashboard: setTitle("History"); SecondFragment fragment2 = new SecondFragment(); FragmentTransaction fragmentTransaction2 = getSupportFragmentManager().beginTransaction(); fragmentTransaction2.replace(R.id.fram, fragment2); fragmentTransaction2.commit(); return true; case R.id.navigation_notifications: setTitle("Schedule"); ThirdFragment fragment3 = new ThirdFragment(); FragmentTransaction fragmentTransaction3 = getSupportFragmentManager().beginTransaction(); fragmentTransaction3.replace(R.id.fram, fragment3); fragmentTransaction3.commit(); return true; } return false; } }; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main_page); BottomNavigationView navigation = (BottomNavigationView) findViewById(R.id.navigation); navigation.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener); setTitle("Map"); FirstFragment fragment = new FirstFragment(); FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction(); fragmentTransaction.replace(R.id.fram, fragment); fragmentTransaction.commit(); } }
我删除了它并添加了这个:C:\ProgramData\Oracle\Java\javapath
之后,编译和执行我的文件均按预期工作。
另请参阅:Helpful link