Intellij IDEA Error: Could not find or load main class org.jetbrains.jps.cmdline.Launcher in Scala Project - scala

I am facing the following error when I click Run from simple Hello World program of Scala. I am unable to find any solution as I am beginner in the Java field.
I am currently using IntelliJ IDEA 2021.2.3 which I am trying to integrate with Scala but to no avail.I am following this tutorial to run the Scala Program and Install all the required softwares and libraries as mentioned in this link.
https://www.guru99.com/scala-tutorial.html
Screenshot - Intellij IDEA Error for Scala Program
"C:\Program Files\Java\jdk1.8.0_144\bin\java.exe" -Xmx700m -Djava.awt.headless=true -Djava.endorsed.dirs=\"\" -Dpreload.project.path=D:/Scala-Projects -Dpreload.config.path=C:/Users/Khalid/AppData/Roaming/JetBrains/IdeaIC2021.2/options -Dcompile.parallel=false -Drebuild.on.dependency.change=true -Djdt.compiler.useSingleThread=true -Daether.connector.resumeDownloads=false -Dio.netty.initialSeedUniquifier=-2427656205608767245 -Dfile.encoding=windows-1252 -Duser.language=en -Duser.country=US -Didea.paths.selector=IdeaIC2021.2 -Didea.home.path=D:/Softwares/ideaIC-2021.2.3.win -Didea.config.path=C:/Users/Khalid/AppData/Roaming/JetBrains/IdeaIC2021.2 -Didea.plugins.path=C:/Users/Khalid/AppData/Roaming/JetBrains/IdeaIC2021.2/plugins -Djps.log.dir=C:/Users/Khalid/AppData/Local/JetBrains/IdeaIC2021.2/log/build-log -Djps.fallback.jdk.home=D:/Softwares/ideaIC-2021.2.3.win/jbr -Djps.fallback.jdk.version=11.0.12 -Dio.netty.noUnsafe=true -Djava.io.tmpdir=C:/Users/Khalid/AppData/Local/JetBrains/IdeaIC2021.2/compile-server/helloworld_14920d90/_temp_ -Djps.backward.ref.index.builder=true -Dkotlin.incremental.compilation=true -Dkotlin.incremental.compilation.js=true -Dkotlin.daemon.enabled -Dkotlin.daemon.client.alive.path=\"C:\Users\Khalid\AppData\Local\Temp\kotlin-idea-3911355212386532999-is-running\" -Dtmh.instrument.annotations=true -Dtmh.generate.line.numbers=true -Dcompile.parallel.max.threads=4 -Dcompile.parallel=true -Dscala.compile.server.socket.connect.timeout.milliseconds=10000 -Dscala.compiler.indices.rebuild=true -classpath "D:/Softwares/ideaIC-2021.2.3.win/plugins/java/lib/jps-launcher.jar;C:/Program Files/Java/jdk1.8.0_144/lib/tools.jar" org.jetbrains.jps.cmdline.Launcher D:/Softwares/ideaIC-2021.2.3.win/lib/annotations.jar;D:/Softwares/ideaIC-2021.2.3.win/lib/slf4j.jar;D:/Softwares/ideaIC-2021.2.3.win/plugins/java/lib/jps-builders.jar;D:/Softwares/ideaIC-2021.2.3.win/lib/kotlin-stdlib-jdk8.jar;D:/Softwares/ideaIC-2021.2.3.win/lib/jps-model.jar;D:/Softwares/ideaIC-2021.2.3.win/plugins/java/lib/javac2.jar;D:/Softwares/ideaIC-2021.2.3.win/lib/forms_rt.jar;D:/Softwares/ideaIC-2021.2.3.win/plugins/java/lib/maven-resolver-transport-file-1.3.3.jar;D:/Softwares/ideaIC-2021.2.3.win/lib/util.jar;D:/Softwares/ideaIC-2021.2.3.win/lib/protobuf-java-3.15.8.jar;D:/Softwares/ideaIC-2021.2.3.win/lib/platform-api.jar;D:/Softwares/ideaIC-2021.2.3.win/lib/jna-platform.jar;D:/Softwares/ideaIC-2021.2.3.win/plugins/java/lib/aether-dependency-resolver.jar;D:/Softwares/ideaIC-2021.2.3.win/plugins/java/lib/jps-javac-extension-1.jar;D:/Softwares/ideaIC-2021.2.3.win/plugins/java/lib/jps-builders-6.jar;D:/Softwares/ideaIC-2021.2.3.win/lib/jna.jar;D:/Softwares/ideaIC-2021.2.3.win/lib/idea_rt.jar;D:/Softwares/ideaIC-2021.2.3.win/lib/3rd-party.jar;D:/Softwares/ideaIC-2021.2.3.win/plugins/java/lib/maven-resolver-connector-basic-1.3.3.jar;D:/Softwares/ideaIC-2021.2.3.win/plugins/java/lib/maven-resolver-transport-http-1.3.3.jar;D:/Softwares/ideaIC-2021.2.3.win/plugins/Kotlin/lib/kotlin-reflect.jar;D:/Softwares/ideaIC-2021.2.3.win/plugins/Kotlin/lib/kotlin-plugin.jar;D:/Softwares/ideaIC-2021.2.3.win/plugins/IntelliLang/lib/java-langInjection-jps.jar;D:/Softwares/ideaIC-2021.2.3.win/plugins/eclipse/lib/eclipse-jps.jar;D:/Softwares/ideaIC-2021.2.3.win/plugins/eclipse/lib/eclipse-common.jar;D:/Softwares/ideaIC-2021.2.3.win/plugins/javaFX/lib/javaFX-jps.jar;D:/Softwares/ideaIC-2021.2.3.win/plugins/javaFX/lib/javaFX-common.jar;D:/Softwares/ideaIC-2021.2.3.win/plugins/ant/lib/ant-jps.jar;D:/Softwares/ideaIC-2021.2.3.win/plugins/Groovy/lib/groovy-jps.jar;D:/Softwares/ideaIC-2021.2.3.win/plugins/Groovy/lib/groovy-constants-rt.jar;D:/Softwares/ideaIC-2021.2.3.win/plugins/uiDesigner/lib/jps/java-guiForms-jps.jar;D:/Softwares/ideaIC-2021.2.3.win/plugins/maven/lib/maven-jps.jar;D:/Softwares/ideaIC-2021.2.3.win/plugins/gradle-java/lib/gradle-jps.jar;D:/Softwares/ideaIC-2021.2.3.win/plugins/Kotlin/lib/jps/kotlin-jps-plugin.jar;D:/Softwares/ideaIC-2021.2.3.win/plugins/Kotlin/lib/kotlin-jps-common.jar;D:/Softwares/ideaIC-2021.2.3.win/plugins/Kotlin/lib/kotlin-common.jar;D:/Softwares/ideaIC-2021.2.3.win/plugins/space/lib/space-java-jps.jar;D:/Softwares/ideaIC-2021.2.3.win/plugins/devkit/lib/devkit-jps.jar;C:/Users/Khalid/AppData/Roaming/JetBrains/IdeaIC2021.2/plugins/Scala/lib/scala-library.jar;C:/Users/Khalid/AppData/Roaming/JetBrains/IdeaIC2021.2/plugins/Scala/lib/compiler-shared.jar;C:/Users/Khalid/AppData/Roaming/JetBrains/IdeaIC2021.2/plugins/Scala/lib/jps/nailgun.jar;C:/Users/Khalid/AppData/Roaming/JetBrains/IdeaIC2021.2/plugins/Scala/lib/jps/compiler-jps.jar;C:/Users/Khalid/AppData/Roaming/JetBrains/IdeaIC2021.2/plugins/Scala/lib/jps/sbt-interface.jar;C:/Users/Khalid/AppData/Roaming/JetBrains/IdeaIC2021.2/plugins/Scala/lib/jps/incremental-compiler.jar;C:/Users/Khalid/AppData/Roaming/JetBrains/IdeaIC2021.2/plugins/Scala/lib/jps/scala-parallel-collections.jar;C:/Users/Khalid/AppData/Roaming/JetBrains/IdeaIC2021.2/plugins/Scala/lib/spray-json_2.13-1.3.5.jar;C:/Users/Khalid/AppData/Roaming/JetBrains/IdeaIC2021.2/plugins/Scala/lib/scala-compiler-indices-protocol_2.12-0.1.1.jar org.jetbrains.jps.cmdline.BuildMain 127.0.0.1 57901 33b87547-d627-4a07-bd5f-0b53060f32c9 C:/Users/Khalid/AppData/Local/JetBrains/IdeaIC2021.2/compile-server
Error: Could not find or load main class org.jetbrains.jps.cmdline.Launcher

Make sure you are correctly specified the main class in Run configuration dialog:
You can open it from the main toolbar:

Related

Java Illegal Argument Exception thrown when opening NetLogo model in Jython

I am trying to control NetLogo's API using Jython 2.7.0 (on Java 1.8.0_131) running on OS X El Capitan (10.11.6) to run experiments. In trying to run the following code:
import site
site.addsitedir("/Users/nqe/NetLogo/NetLogo 6.0.1/Java/")
import org.nlogo.headless.HeadlessWorkspace as hw
workspace = hw.newInstance()
workspace.open("models/Sample Models/Earth Science/Fire.nlogo")
workspace.command("set density 62")
workspace.command("random-seed 0")
workspace.command("setup")
workspace.command("repeat 50 [ go ]")
print (workspace.report("burned-trees"))
workspace.dispose()
I get the following error:
at scala.Predef$.require(Predef.scala:264)
at org.nlogo.generate.PrimitiveCache$.read$1(PrimitiveCache.scala:22)
at org.nlogo.generate.PrimitiveCache$.$anonfun$getClassReader$1(PrimitiveCache.scala:26)
at scala.collection.mutable.AbstractMap.getOrElseUpdate(Map.scala:80)
at org.nlogo.generate.PrimitiveCache$.getClassReader(PrimitiveCache.scala:26)
at org.nlogo.generate.PeepholeSafeChecker.processClass(PeepholeSafeChecker.scala:49)
at org.nlogo.generate.PeepholeSafeChecker.isSafe(PeepholeSafeChecker.scala:42)
at org.nlogo.generate.Generator$InstructionGenerator.generateInstruction(Generator.scala:190)
at org.nlogo.generate.Generator$InstructionGenerator.generateBodyMethod(Generator.scala:124)
at org.nlogo.generate.Generator$InstructionGenerator.generate(Generator.scala:99)
at org.nlogo.generate.Generator.org$nlogo$generate$Generator$$recurse(Generator.scala:29)
at org.nlogo.generate.Generator.$anonfun$recurse$1(Generator.scala:31)
at scala.collection.TraversableLike.$anonfun$map$1(TraversableLike.scala:234)
at scala.collection.mutable.ArrayOps$ofRef.foreach(ArrayOps.scala:193)
at scala.collection.TraversableLike.map$(TraversableLike.scala:234)
at scala.collection.mutable.ArrayOps$ofRef.map(ArrayOps.scala:193)
at org.nlogo.generate.Generator.org$nlogo$generate$Generator$$recurse(Generator.scala:31)
at org.nlogo.generate.Generator.$anonfun$generate$1(Generator.scala:25)
at scala.collection.TraversableLike.$anonfun$map$1(TraversableLike.scala:234)
at scala.collection.mutable.ArrayOps$ofRef.foreach(ArrayOps.scala:193)
at scala.collection.TraversableLike.map$(TraversableLike.scala:234)
at scala.collection.mutable.ArrayOps$ofRef.map(ArrayOps.scala:193)
at org.nlogo.generate.Generator.generate(Generator.scala:25)
at org.nlogo.compile.CompilerMain$.assembleProcedure(CompilerMain.scala:79)
at org.nlogo.compile.CompilerMain$.$anonfun$compile$2(CompilerMain.scala:55)
at scala.collection.TraversableLike.$anonfun$map$1(TraversableLike.scala:234)
at scala.collection.immutable.List.foreach(List.scala:378)
at scala.collection.TraversableLike.map$(TraversableLike.scala:234)
at scala.collection.immutable.List.map(List.scala:284)
at org.nlogo.compile.CompilerMain$.compile(CompilerMain.scala:55)
at org.nlogo.compile.Compiler.compileProgram(Compiler.scala:52)
at org.nlogo.headless.HeadlessModelOpener.openFromModel(HeadlessModelOpener.scala:54)
at org.nlogo.headless.HeadlessWorkspace.openModel(HeadlessWorkspace.scala:532)
at org.nlogo.headless.HeadlessWorkspace.open(HeadlessWorkspace.scala:499)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
java.lang.IllegalArgumentException: java.lang.IllegalArgumentException: requirement failed
In case the "import site" part is not clear, I did the following:
Create a jython script to write all .jar files in "/Users/nqe/NetLogo/NetLogo 6.0.1/Java/" to a .pth file.
I then placed this .pith file into said the .../Java/ directory with the .jar files.
This allows me to access all the .jar dependencies from sys.path when needing to the import various API features of NetLogo.
I can't figure out exactly what causes this error, for in running on python interactive mode, I was able to successfully create a new instance of NetLogo JVM using the hw.newInstance() command (I could see a Java icon pop up when running this code), and the open command threw the appropriate errors if I fail to specify a url, for example.
Because of this, I thought it might have something to do with my JVM not being configured properly, so I tried a few things.
First, I checked that I was able to actually run the java example of controlling NetLogo API in headless mode found here: https://github.com/NetLogo/NetLogo/wiki/Controlling-API. I was able to run the code given here using these commands:
javadir=/Users/nqe/NetLogo/ControlAPI/
netjardir=/Users/nqe/NetLogo/NetLogo\ 6.0.1/Java/netlogo-mac-app.jar
javaname=Example1
javac -cp "${javadir}":"${netjardir}" $javaname.java
java -cp "${javadir}":"${netjardir}" $javaname
without changing any JVM settings manually. Nevertheless, I went ahead and tried changing things in my JVM settings when running the jython code such as the path to docs and extensions, but in particular, to the ./lib directory. Unfortunately, specifying the following JVM setting:
-Djava.library.path=~/JRE/Contents/Home/jre/lib/
does nothing to help the cause. Note that the ~ here is short for being in the NetLogo 6.0.1 directory and that this was the only lib directory I could find.
Finally, I discord this: when I try to run the above jython script when only specifying the path to netlogo-mac-app.jar, I AM NOT ABLE TO IMPORT the headless class stuff. Hence, the compilation/ running of the java while specifying only this one .jar classpath could possibly be somehow accessing some useful meta-data necessary for NetLogo to work (I don't know if this is possible with my level of Java background).
Upon thinking this, I found a NetLogo.cfg file in ~/NetLogo 6.0.1.app/Contents/Java/ that contains the following info:
[Application]
app.name=NetLogo
app.mainjar=netlogo-mac-app.jar
app.version=6.0.1
app.preferences.id=org/nlogo/app
app.mainclass=org/nlogo/app/MacApplication
app.classpath=$APPDIR/../../Java/args4j-2.0.12.jar:$APPDIR/../../Java/asm-5.0.3.jar:$APPDIR/../../Java/asm-5.0.3.jar:$APPDIR/../../Java/asm-all-5.0.4.jar:$APPDIR/../../Java/asm-all-5.0.4.jar:$APPDIR/../../Java/asm-analysis-5.0.3.jar:$APPDIR/../../Java/asm-analysis-5.0.3.jar:$APPDIR/../../Java/asm-tree-5.0.3.jar:$APPDIR/../../Java/asm-tree-5.0.3.jar:$APPDIR/../../Java/asm-util-5.0.3.jar:$APPDIR/../../Java/asm-util-5.0.3.jar:$APPDIR/../../Java/behaviorsearch.jar:$APPDIR/../../Java/commons-codec-1.10.jar:$APPDIR/../../Java/commons-codec-1.10.jar:$APPDIR/../../Java/commons-logging-1.1.1.jar:$APPDIR/../../Java/commons-logging-1.1.1.jar:$APPDIR/../../Java/gluegen-rt-2.3.2.jar:$APPDIR/../../Java/gluegen-rt-2.3.2.jar:$APPDIR/../../Java/httpclient-4.2.jar:$APPDIR/../../Java/httpclient-4.2.jar:$APPDIR/../../Java/httpcore-4.2.jar:$APPDIR/../../Java/httpcore-4.2.jar:$APPDIR/../../Java/httpmime-4.2.jar:$APPDIR/../../Java/httpmime-4.2.jar:$APPDIR/../../Java/java-objc-bridge-1.0.0.jar:$APPDIR/../../Java/jcommon-1.0.16.jar:$APPDIR/../../Java/jfreechart-1.0.13.jar:$APPDIR/../../Java/jhotdraw-6.0b1.jar:$APPDIR/../../Java/jhotdraw-6.0b1.jar:$APPDIR/../../Java/jmf-2.1.1e.jar:$APPDIR/../../Java/jmf-2.1.1e.jar:$APPDIR/../../Java/jna-4.2.2.jar:$APPDIR/../../Java/jogl-all-2.3.2.jar:$APPDIR/../../Java/jogl-all-2.3.2.jar:$APPDIR/../../Java/json-simple-1.1.1.jar:$APPDIR/../../Java/json-simple-1.1.1.jar:$APPDIR/../../Java/log4j-1.2.16.jar:$APPDIR/../../Java/log4j-1.2.16.jar:$APPDIR/../../Java/macro-compat_2.12-1.1.1.jar:$APPDIR/../../Java/macro-compat_2.12-1.1.1.jar:$APPDIR/../../Java/netlogo-6.0.1.jar:$APPDIR/../../Java/netlogo-6.0.1.jar:$APPDIR/../../Java/netlogo-mac-app.jar:$APPDIR/../../Java/parboiled-core-1.1.7.jar:$APPDIR/../../Java/parboiled-core-1.1.7.jar:$APPDIR/../../Java/parboiled-java-1.1.7.jar:$APPDIR/../../Java/parboiled-java-1.1.7.jar:$APPDIR/../../Java/parboiled_2.12-2.1.3.jar:$APPDIR/../../Java/parboiled_2.12-2.1.3.jar:$APPDIR/../../Java/pegdown-1.6.0.jar:$APPDIR/../../Java/pegdown-1.6.0.jar:$APPDIR/../../Java/picocontainer-2.13.6.jar:$APPDIR/../../Java/picocontainer-2.13.6.jar:$APPDIR/../../Java/rsyntaxtextarea-2.6.0.jar:$APPDIR/../../Java/rsyntaxtextarea-2.6.0.jar:$APPDIR/../../Java/scala-library-2.12.0.jar:$APPDIR/../../Java/scala-library-2.12.1.jar:$APPDIR/../../Java/scala-library-2.12.1.jar:$APPDIR/../../Java/scala-parser-combinators_2.12-1.0.5.jar:$APPDIR/../../Java/scala-parser-combinators_2.12-1.0.5.jar:$APPDIR/../../Java/shapeless_2.12-2.3.2.jar:$APPDIR/../../Java/shapeless_2.12-2.3.2.jar
app.runtime=$APPDIR/../../JRE
app.identifier=org.nlogo.app
[JVMOptions]
-Dnetlogo.extensions.dir=$APPDIR/../../extensions
-Dnetlogo.models.dir=$APPDIR/../../models
-Dnetlogo.docs.dir=$APPDIR/../../docs
-Xdock:name=NetLogo
-Dorg.nlogo.mac.appClassName=org.nlogo.app.App$
-Xmx1024m
-Dfile.encoding=UTF-8
-Dapple.awt.graphics.UseQuartz=true
[JVMUserOptions]
[ArgOptions]
This seemed promising, but literally deleting this file had no affect on my ability to run NetLogo by opening the application/ using the Control API with Java method. As such, I am stumped, so any help would be greatly appreciated.

PHP Fatal error: Class 'RemoteWebElement' not found in

I have a symfony project that run normal in command line:
php app/console server:run
But, I want to run inside PhpStorm. When I try to do this, it gives the fatal error:
PHP Fatal error: Class 'RemoteWebElement' not found in
I already tried to look the oficial documentation of the classe:
http://facebook.github.io/php-webdriver/classes/RemoteWebElement.html. But I didn't found information that culd help me.
I also added the compose dependency:
composer require facebook/webdriver
But had no effect!
=======================================
I'll explain step-step how to get this the bug (It will be very long!):
I have:
PHP 5.5.9
PhpStorm 10.0.3
composer 1.0-dev (7117a5775ffdcdfd31bbd52a138a6f9c65e7e3c2) 2016-02-03
So, create a new symfony project (current version 3.0) and add composer dependencies:
symfony new project
cd project
composer update
Then, open this project inside of phpstorm and I configure settings for to run the project:
Settings -> Languages & Frameworks -> PHP
"PHP language level": 5.5
"Interpreter": 5.5.9
Add through plus(+) the PHP folder:
/usr/share/php
Click 'OK'
Now, try to run de project through PhpStorm by the shortcut:
Ctrl+Shif+F10.
Will appear the bug:
PHP Fatal error: Class
'Symfony\Bundle\FrameworkBundle\Test\WebTestCase' not found in
Solve this by this way inside of PhpStorm:
Settings -> Languages & Frameworks -> PHP -> PHPUnit
Choose: "Use custom autoloader"
And, in the field "Path to script", informe the autoloader's address. For example:
/home/murilo/git/slu/app/autoload.php. Click 'OK'.
Again, try to run de project through PhpStorm by the shortcut:
Ctrl+Shif+F10
Will appear the bug:
PHP Fatal error: Class 'Doctrine\Tests\Common\Cache\CacheTest' not
found in
Solve this through this command inside the project folder:
composer require maslosoft/cachetest:dev-master -n --no-progress
For the last time, try to run de project through PhpStorm by the shortcut:
Ctrl+Shif+F10
Will appear the bug:
PHP Fatal error: Class 'RemoteWebElement' not found in
I'm at this bug.
Please, someone knows how I can overcome this bug? o.O
I struggled with the same exact issue as you have described. After breaking my head for most of the day with this problem, I found the issue.
When you execute the command php app/console server:run in command line, it sets up a server and runs the website. However, when you run the project in PHPStorm, it doesn't actually run it as a server but runs it as a PHPUnit. What you need to do is configure a PHP Web Application in PHPStorm and run that.
Check the image below where I have configured the website. When I run the Web Application, it will run by the url and it will show up in your browser.

JFlex - how to test the scanner

I've just started to learn JFlex. I am studying one of the official Jflex examples, which is a scanner for the Java language. In the Readme file it says:
The scanner (without parser attached) can be test with:
java TestLexer <inputfiles>
But when I tried this in cmd, I got an error message instead, saying 'Could not find or load main class TestLexer'.Does anyone know why? Thank you in advance.
To test the lexer for Java, JFlex has a depency to the CUP parser generator, did you installed it?
Then there is several commands to make before being able to run the lexer:
jflex unicode.flex
jflex java.flex
java java_cup.Main -interface < java12.cup
javac JavaParser.java TestLexer.java
For the third command, you need to have the java-cup-11a.jar somewhere in your classpath.
Only then you would be able to test the parser:
java JavaParser <inputfiles>
or the scanner:
java TestLexer <inputfiles>

gwt-preprocessor - Unknown argument: -remoteUI

I'm trying to use the gwt-preprocessor for reflection with gwt. I created a run configuration for it in Eclipse. It seems to run the preprocessor fine, but after that I think it's trying to run the gwt compiler when I get "Unknown argument: -remoteUI".
If I remove the "remoteUI" argument from the run configuration, then I get the following error: Missing required argument 'module[s]'
If someone has a working configuration in Eclipse, can you specify the exact steps for installing gwt-preprocessor? Thanks!
If you are using dev mode please use org.hawk.gwt.ppc.DevModeWrapper instead of org.hawk.gwt.ppc.CompilerWrapper as main class. Here is my example how I'm creating debug configurations:
Create web application configuration (gwt web application).
On the main tab replace DevMode class with org.hawk.gwt.ppc.DevModeWrapper
Here is example of Arguments->Program arguments section:
-Puse-generics -Pprocess-annotations -Preflect=org.hawk.gwtppc.webtest.tests.** -remoteUI "${gwt_remote_ui_server_port}:${unique_id}" -logLevel INFO -codeServerPort 9997 -port 8888 -war /Users/alexbereznevatiy/dev/gwtppc/webtests/war org.hawk.gwtppc.webtest.webtest
The rest is pretty much the same. Make sure you are including proprocessor binary to the classpath tab as well as on sources tab.
Feel free to ask any questions or register bugs in gwt-preprocessor (if you find any).

Why would Eclipse not be able to include a file when running a PHPUnit test?

I have the following class and unit test in a PHP project in Eclipse:
I know my unit test works as I can run it at the command line:
Now I want to run this test from Eclipse. I set up PHP Unit in Eclipse like this:
However, when I run the PHPUnit tests:
It tells me that it can't include the class file:
/usr/bin/php -c /var/folders/UA/UAv38snBHd0QMgEPMCmM9U+++TM/-Tmp-/zend_debug/session4910937990995915704.tmp -d asp_tags=off /Applications/eclipse/plugins/org.phpsrc.eclipse.pti.tools.phpunit_0.5.0.R20101103000000/php/tools/phpunit.php --log-junit /var/folders/UA/UAv38snBHd0QMgEPMCmM9U+++TM/-Tmp-/pti_phpunit/phpunit.xml /Volumes/data/domains/et/extjslayout/phpunittest/tests
PHP Warning: include_once(../Product.php): failed to open stream: No such file or directory in /Volumes/data/domains/et/extjslayout/phpunittest/tests/ProductTest.php on line 3
PHP Warning: include_once(): Failed opening '../Product.php' for inclusion (include_path='/usr/local/PEAR') in /Volumes/data/domains/et/extjslayout/phpunittest/tests/ProductTest.php on line 3
PHP Fatal error: Class 'Product' not found in /Volumes/data/domains/et/extjslayout/phpunittest/tests/ProductTest.php on line 9
Why would PHPUnit be able to find the class when run from the command line but not when run from Eclipse?
When you start something from the command line, the "current directory" has a well-defined meaning: It's the directory where you started the command.
In Eclipse, what is the "current directory"? It's probably the directory from which you started Eclipse or maybe the folder in which Eclipse is installed.
I haven't used PHP in Eclipse before but for other languages, I can set the current directory in the launch config somewhere. If that doesn't work, define a variable which points to your project and then use absolute paths (using that variable as a starting point).
Have same problem. Found only solution by creating tests with internal PHPUnit wizard like at this screenshot:
Source: HowTo create a Test Case Class from a PHP Class
But following investigate show that your test case file should contain reference to tested code for example like this: require_once 'C:\Apache2\htdocs\jobeet\src\Ibw\JobeetBundle\Utils\Jobeet.php';
Other experiments with plugin config not bringing luck. So in my opinion PHPUnit from PHP Tools not well developed plugin. Consider using MakeGood plugin as better alternative.