简体   繁体   English

Play Framework 2.1发生javac错误

[英]javac error with Play framework 2.1

I'm having a very hard time making a simple Play 2 project (Scala) to work with IntelliJ on Windows 8 64-bit. 我很难制作一个简单的Play 2项目(Scala)以在Windows 8 64位上使用IntelliJ。 I made a project and always get the error: 我做了一个项目,总是得到错误:

Play 2 compiler
:  (compile:compile) java.io.IOException: Cannot run program "javac": CreateProcess error=2, The system cannot find the file specified

I added javac to my path ("C:\\Program Files\\Java\\jdk1.7.0_45\\bin") and even JAVA_HOME (set to "C:\\Program Files\\Java\\jdk1.7.0_45"). 我将javac添加到了我的路径(“ C:\\ Program Files \\ Java \\ jdk1.7.0_45 \\ bin”),甚至还添加了JAVA_HOME(设置为“ C:\\ Program Files \\ Java \\ jdk1.7.0_45”)。 I works: I can call javac from the command prompt... but I still get the same annoying error when I try to Make the project with IntelliJ. 我的作品:我可以从命令提示符下调用javac ...,但是当我尝试使用IntelliJ创建项目时,我仍然遇到同样令人讨厌的错误。

What I did, step by step: 我所做的步骤:

  1. Install jdk-7u45-windows-x64.exe. 安装jdk-7u45-windows-x64.exe。 Add to PATH. 添加到PATH。
  2. Install latest IntelliJ IDEA 12 (Ultimate) 安装最新的IntelliJ IDEA 12(最终版)
  3. Open IntelliJ and install Scala and Play plugins. 打开IntelliJ并安装Scala和Play插件。
  4. Create a new Play framework project, select JDK and a version of Play (2.1). 创建一个新的Play框架项目,选择JDK和一个Play版本(2.1)。
  5. Try to build the basic project without making any modification to the code and get the javac error. 尝试在不对代码进行任何修改的情况下构建基础项目,并得到javac错误。

I'm completely new to IntelliJ (I hope it gets more fun!) but looking at "Project Structure": everything looks fine, bth the Java SDK and Scala 2.10 compilers are selected... 我是IntelliJ的新手(希望它能带来更多乐趣!),但请看“项目结构”:一切看起来都很好,选择了Java SDK和Scala 2.10编译器...

I too got this error when I started my Sample Play App using Activator 1.0.13. 当我使用Activator 1.0.13启动示例播放应用时,我也遇到了此错误。 I checked my JAVA_HOME and it was showing the correct installation path. 我检查了JAVA_HOME,它显示了正确的安装路径。 To solve this problem, I entered into the console and issued following command:- 为了解决这个问题,我进入控制台并发出以下命令:

set javaHome := Some(new java.io.File("/usr/lib/jvm/jdk1.7.0_45"))

After this, it started working. 此后,它开始工作。

even though you might have jdk bin directory in PATH env variable, this problem can occur. 即使您可能在PATH env变量中有jdk bin目录,也会出现此问题。 To fix this, put path of jdk bin (not of jre bin) at the beginning of PATH env variable, just in case any other PATH value is getting picked up first for javac (might have jre bin dir also in PATH env variable before..for example) 要解决此问题,请将jdk bin的路径(不是jre bin的路径)放在PATH env变量的开头,以防万一其他任何PATH值都首先被javac获取(之前可能在PATH env变量中也有jre bin dir)。 。例如)

It's evident that your java installation did not complete successfully 显然,您的Java安装未成功完成

at your command prompt type: java -version 在命令提示符下键入:java -version

If it works, next step is to ensure that 'javac' is on system/user PATH 如果可行,则下一步是确保“ javac”位于系统/用户PATH上

  1. Add this to your bash profile 将此添加到您的bash个人资料

export $PATH=$PATH:${JAVA_HOME_DIR}/bin 导出$ PATH = $ PATH:$ {JAVA_HOME_DIR} / bin

Reinitialize your profile by executing 通过执行重新初始化您的配置文件

source ~/.bash_profile 来源〜/ .bash_profile

Then retry. 然后重试。

if you are using play 2.1.X then go to your project directory and inside there is a folder name project . 如果您使用的是play 2.1.X则转到项目目录,并且在其中有一个文件夹名称project go also inside this directory also and you will find out one file is there Build.scala and open this file and inside this file 也进入该目录,您将找到一个文件Build.scala然后打开该文件并在此文件中

write javaCore inside app dependecy in build.scala javaCore在build.scala 应用dependecy

like this 像这样

 val appDependencies = Seq(
      javaCore
    )

i think it will help you 我认为它将帮助您

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM