Kotlin in VScode - kotlin

today I tried to run easy Kotlin code in VScode, but there is error:
cd "c:\Users\<MyPcUser>\<SomeMoreFolders>\Visual Studio\Kotlin (There is the file saved) \" && kotlinc main.kt -include-runtime -d main.jar && java -jar main.jar
'kotlinc' is not recognized as an internal or external command,
operable program or batch file.
I have installed "Code Runner" extension and "Kotlin Language" extension. I searched on the internet and youtube, but in tutorials, it worked for them.
Can somebody help please.
Thanks

I had same issue and on both of my linux and windows machies. And the fix is essentially the same. You need to add kotlin compiler to your PATH variable.
I suppose you also have your kotlin installed from previously installing IntelliJ IDEA so to help you find it path is probably something like:
"C:\Program Files\JetBrains\IntelliJ IDEA 2022.2.1\plugins\Kotlin\kotlinc\bin"
After you added it to path restart PC if you are on Windows or logout/login if you are on linux
To test execute this command in terminal
kotlinc -version
Should return something like
kotlinc-jvm 1.7.10-release-334 (JRE 11.0.16+11-LTS-199)
and your should be able to run from VS code

Related

Running software build in MSYS2 MINGW32 shell

I'm trying to run a piece of software I built in MSYS2 MINGW32 shell. The software is 32bits (don't have time to port it to 64bits) and there is one statically linked executable. Here is how I setup the build environment:
Installed a fresh copy of MSYS2;
$ pacman -Syu
Installed the following packages: git mingw-w64-i686-gcc mingw-w64-i686-cmake mingw-w64-i686-SDL mingw-w64-i686-SDL_mixer mingw-w64-i686-zlib mingw-w64-i686-libpng mingw-w64-i686-make
Git checkout the repo
Run the build in CMake
Build runs fine and the exe is generated.
Now the problem starts: the executable can't run and displays an error message about missing DLLs. I copied the missing DLLs to the same folder of the executable, and them another error message pops up complaining about error 0xC000007B, which I tracked down to be missing dependencies. After a while I figured out that the problem was that some of the DLLs is missing a dependency itself. Copied this last dependency to the folder.
Now, the big question: I can run the exe perfectly fine in the MINGW32 shell but I can't run it neither in cmd.exe nor by double-clicking in Windows Explorer and this is a problem (I can't ship a software this way). Is there any way to produce a binary that is able to run from explorer and from cmd.exe? What is the cause of this problem? Can it be mitigated?
I solved my problem!
After a lot of research, I realized that nothing was wrong with my MSYS2 build/setup/dependencies. The real problem was that CMake hide one parameter for the linker: -mwindows. Actually, the CMake find_package routine from one of the libraries I'm using (SDL) added this parameter to the linker command line parameters.
Adding a -mconsole to the linker parameters (using add_link_options("-mconsole")) solved the problem. The CLI now works as expected.
Thank you all for your help.

How do I use GMake on Windows

I've downloaded the source files for the TBB libraries, with the intent to build them and link them into my CMake project. The readme file says "type 'gmake' in this directory to build and test."
My question is - how do I run gmake on a Windows machine.
The solution in this answer didn't work for me. This is what I get:
From the log I see that make unable to find Microsoft compiler cl.exe. To fix this, you must use one of the "Visual Studio command prompt"-s, those are cmd with environments targeted to command-line tools.
If you use MigGW by chance, the command should be
make compiler=gcc.
In this case, path environment variable should contain path to MigGW.

Getting started with SableCC

I am a total beginner in programming and for school i have to make a little SableCC project. However im not sure how to use SableCC properly.
I have downloaded it from sablecc.org and i did what was said in the readme to install it.
So after installing with the java -jar lib/sablecc.jar command the console tells me how the usage works,
like for example
sablecc --license
or to use
sablecc [-d destination]
to where i want sablecc to work (i guess).
However, when i use anything from this list it just says:
Sablecc is not recognized as an internal or external command
What have i done wrong? Thanks!
I followed also the instruction of [README.html][1] for ANT and it worked fine for me.
edit: I put some commands here in case the link is unavailable some time.
After downloading, follow the next steps:
Decompress the file sablecc-3.2.tar.gz or sablecc-3.2.zip: tar -xzvf sablecc-3.2.tar.gz or jar -xvf sablecc-3.2.zip
Go to the created directory: cd sablecc-3.2
You will find an executable sablecc.jar file in the lib directory: java -jar lib/sablecc.jar
This is it.
If you have Ant installed on your system, you can install SableCC with the command:
ant -Dinstall.dir=destination install

How to run a java application created in intelliJ at the command line?

I have a simple "Hello World" application created in intelliJ using Java. How do I run the application outside of intelliJ at a terminal command line?
First result in google: http://www.skylit.com/javamethods/faqs/javaindos.html
Run Command Prompt (found under All Programs/Accessories in the Start menu). Type
C:\> cd \mywork
This makes C:\mywork the current directory.
C:\mywork> dir
This displays the directory contents. You should see HelloWorld.java among the files.
C:\mywork> set path=%path%;C:\Program Files\Java\jdk1.5.0_09\bin
This tells the system where to find JDK programs.
C:\mywork> javac HelloWorld.java
This runs javac.exe, the compiler. You should see nothing but the next system prompt...
C:\mywork> dir
javac has created the HelloWorld.class file. You should see HelloWorld.java and HelloWorld.class among the files.
C:\mywork> java HelloWorld
This runs the Java interpreter. You should see the program output:
Hello, World!
I have been struggling to output java code to terminal these days. I finally found a way to do that. Following are my steps hope this is of some use to you.
Get the class path where your main method locates and switch to that directory. In my case, my main stays in
Set path of your jdk, for example
set path=C:\Program Files\Java\jdk1.8.0_66\bin
Compile and run your code. Remember to include your package name. About package please have a look of this site: http://www.javatpoint.com/package
In my case, my main method is in Main.java, and Main.java is included in package sample
You can do exactly the same steps to get your output from cmd, command line console.

How to run CMakesetup?

I downloaded cmake and I wanted to build LSHKIT using this command:
cmakesetup ", where is the LSHKIT root directory
but it gives me this error:
'cmakesetup' is not recognized as an internal or external command,
operable program or batch file.
could you tell me what is wrong?
BTW, I am working in windows 7.
CMakeSetup is an older program that no longer builds with the most recent releases of CMake. Use "cmake-gui" instead of "CMakeSetup"...