Hello World Compile Error - Android - java

I'm trying to setup the android dev kit, I've installed everything and tried to setup a Hello World activity, however when I build the project I get the error:
Cannot run program "C:\Program Files\Java\jdk1.7.0_45\bin\java" (in directory "C:\Users\Matt\.IntelliJIdea13\system\compile-server"): CreateProcess error=2, The system cannot find the file specified
All of this is auto generated from my IDE, so I'm not sure what the problem can be, has anyone encountered this before?

First of all as said in the comment the error is that your file missing, so the first step is to see if the file is even there, if not I would reinstall your jdk (as that file should not be missing).
If the file is there than it is most likely the case that the space in the directory is causing issue for some reason. To fix this you can either manually copy your jdk to a new directory (without a space) and replace your current jdk's location with the new one. You could also uninstall the current java distribution and reinstall the new one in a location without spaces.

Related

How can I get stdlib.jar to work in IntelliJ IDEA?

I​ had used the IntelliJ IDEA installer provided in the booksite for Computer Science: An Interdisciplinary Approach and I had no problem to use the library. However, I noticed that installation had screwed my Git bash display settings, so I uninstalled everything.
Later, I installed the latest version of IntelliJ (2021.3.3), from the JetBrains website and apparently all the previous settings were overwritten, since I could no longer use the library. So, I downgraded back to the version provided in the booksite, however, I still can't use the Std library.
I've tried adding the versions of the library .jar files that I found:
On the Standard Libraries Princeton's webpage
On the Jar Download website
On this post from Stack Overflow
In the .jar file from the hello.zip file I found on this other Princeton webpage
Together and independently to the module and libraries, via IntelliJ IDEA, following the paths: "File > Project settings > Modules > + > JARs or directories" and "File > Project settings > Libraries > + > Java" , respectively, and choosing the corresponding directory/file, with no luck, since I've got the "cannot find symbol" error message:
Barnsley.java:16: error: cannot find symbol
StdDraw.setScale(-0.1, 1.1); // leave a 10% border
^
symbol: variable StdDraw
location: class Barnsley
For literally every single mention of the Std libraries in the code. I​ also tried editing the environment system variables and created a variable named "CLASSPATH" and linked it to the Stdlib.jar file and then, to the .lift folder that came with the hello.zip file, from the first week assignment. Again, no luck, because I kept getting the same error message.
Next up, I typed:
javac -cp stdlib.jar Barnsley.java
In the command line, and although that command itself didn't lead to any error message, when I tried to run the program, typing:
java -cp stdlib.jar Barnsley 10000
This error message showed up:
Error: Could not find or load main class Barnsley
Caused by: java.lang.ClassNotFoundException: Barnsley
I also vainly tried copying and pasting every .java file from Standard libraries webpage to the same directory where I keep the program files.
I know some (maybe lots of people) have asked the same or a similar question before, either here or in other forums, but I've been googling and looking for a solution for three days now and, as you can see, none of the reported solutions that I've found have been of help to me, that's why I decided to ask again, on my own.
Thank you for reading my post and/or for any help you can provide.
PS.: The Barnsley.java file in the error messages corresponds to the one provided in the 5th section of this webpage from the booksite.
[Edit - April 7th, 2022]:
I tried to follow #CrazyCoder advice, so I created a folder named "src", extracted all the files from the stdlib.jar file that came with the hello.zip file into src and also moved Barnsley.java to that folder. Next, Next, I tried to follow the instructions from the webpage he mentioned, as shown in the following screenshot:
And somehow, got the same error message when compiling:
I don't know what went wrong :C Any assistance would be highly appreciated.
[Edit - Later on April 7th, 2022]:
Something weird happened. I downloaded the file provided by #CrazyCorder and there was a warning about Amazon Corretto not being installed, that I decided to ignore.
I tried to run the program from the command line, with no luck, because I got the same error message as always. So, I noticed that there was no JDK assigned to the SDK slot in the Project structure, and I chose to use JDK 18 (following the path "File > Project structure > Project"), which is the one that I had previously installed on my computer, but that didn't really change a thing.
Lastly, I tried to run it from the IDE and that's when it finally worked!!! So, thank you, #CrazyCoder :D I still don't know why it doesn't work from the command line, though...
I also vainly tried copying and pasting every .java file from Standard libraries webpage to the same directory where I keep the program files.
This works just fine, you need to place all the .java files from the stdlib.jar into the sources root directory (marked in blue in the project view). Barnsley.java needs to be in the same directory.
The jar with .class files will not work in the dependencies/classpath as you cannot import classes from the default package in Java.
It was an extremely poor choice to keep the classes in the default package and it's the fault of the creators of this library/course. This simple oversight has caused major headaches over the years.

Terminal command/executable only works in one directory and errors out in any other directory

I just installed Kawa to code some scheme, https://www.gnu.org/software/kawa/index.html.
I'm using MacOs Terminal (my Mac is currently using Big Sur).
I cloned the repo, and followed all the installation steps specified in here: https://www.gnu.org/software/kawa/Source-distribution.html
Also installed dependencies.
The command that starts the program is "Kawa".
Everything works fine if, and only if, I type "Kawa" command in terminal when I'm in the directory that all the files where copied into. The program runs and I'm able to code in scheme. Please note that this is not a local executable, as I don't have to type "./Kawa" for it to work.
However, if I'm in any other directory and I type "Kawa", the following Error gets printed on the console: Could not find or load main class kawa.repl
Caused by: java.lang.ClassNotFoundException: kawa.repl
I'm just learning about unix/linux and don't know much about java, but I'm guessing this has something to do with file paths?
I checked and some of the files were installed in /usr/local/share/kawa in my Mac. If you go through the installation steps that I linked to above, after you run "make install", it says that you have to manually specify:
CLASSPATH=$PREFIX/share/java/kawa.jar
export CLASSPATH
I don't know exactly what that does. I wonder if this is something that I should put in some file, I tried just typing in the terminal and running the "kawa" command after with no success.
Any help will be appreciated, thank you.

Netbeans 10.0 doesn't start in Windows 10 OS

I've just downloaded Netbeans 10.0 and on a Windows 10 64 bit it doesn't start when i execute netbeans64.exe (not even with netbeans.exe)
I removed all the java installations and installed jdk-11.0.2+9 and jdk-11.0.2+9-jre.
Also change the path in the netbeans configuration file to the right java path.
Configured the environment variables PATH and JAVA_HOME.
When run the app nothing happens.
Somebody else with same issue?
I suspect that at the time you installed NetBeans you either had no valid Java installation, or you have changed your Java installation(s) since you installed NetBeans 10.0. In that scenario NetBeans may be unable to start.
To eliminate this as a possibility, explicitly specify the version of Java to be used when starting NetBeans:
Locate the file netbeans.conf. It resides in the etc directory within your NetBeans installation directory.
It is a simple properties file containing name value pairs, with commented lines starting with a # character. Open the file in any text editor.
Locate the line containing the text netbeans_jdkhome=. If that line starts with a # character then delete that character to uncomment the line.
Set the value of that property to the path of the JDK that you want NetBeans to use. For example, on my Windows 10 machine the line looks like this:
netbeans_jdkhome="C:\Java\openJDK\jdk-11.0.2"
Try restarting NetBeans once you have saved your change to netbeans.conf.
If that doesn't work then locate the NetBeans log file, and update your question with the changes logged to it when you attempt to start NetBeans. That log is named messages.log, and is a simple text file. It will reside in a directory named var under your user directory. In my case, on Windows 10, its path is C:\Users\johndoe\AppData\Roaming\NetBeans\10.0\var\log, though obviously it will be different for you.
Solved...
after trying many (MANY) possible solutions the one that worked was renaming the netbeans folder to "Netbeans10" without any "strange" chars.
https://www.youtube.com/watch?v=vt7_6HwCFOU saw this guy and helped me out solved my problem! and it works :)). He put the file on the C drive not inside the (89x)/ programs files. like literally inside the C drive this is how it looks in my folder:
C:\netbeans
Hope it helps.

Can't run Spring Tool Suite installer on Mac OS mavericks?

Whenever I unpack dmg installer I see image containing launcher something like - "Installer - spring-tool-suite-3.6.0.CI-B1808453-e4 ". After I try to launch this installer the loading indicator hangs a little, disappears and nothing happens. I am being forced to migrate to Mac OS due to work environment. I can't even launch the installer.
I suspect this is due to default Apple Java (whatever that means I am not OS X expert) being deleted on this laptop and JDK8 is on the home path.
ALE:~$ echo ${JAVA_HOME}
/Library/Java/JavaVirtualMachines/jdk1.8.0.jdk/Contents/Home/
Well, this forces me to migrate to IntelliJ, but I can't just believe that because of someone else fashion I can't do the work usual way...
Any hint? I don't even get error message..
Had the same issue - download .tar.gz instead of .dmg distribution. There (sts-bundle/sts-3.X.X.RELEASE/STS.app) you'll have STS.app it should run.
Since there is an interest around the question I will post the valid solution. Now what I did which caused an error - deleted default mac os java, and installed java 8 as HOME. Now Eclipse (STS, JasperSoftStudio or whatever) which was installed using dmg will look up the java not anywhere near your HOME directory. (even if it is inside Library as it should be).
Solution: Go to eclipse distribution directory (typically under applications) find the launcher, right click on the launcher, "show package contents", go to MacOS folder, open the .ini file(will have different name for different distributions) and locate -vim entry which statically points to some mac os location attempting to find java lib which is not there and never should be. Make sure your java home path is set, as now it will start to behave normally and look up home path.
If this still did not fix the issue, attempt to delete workspace folder if left from previous installation(or rename it) and play with Locked/Unlocked on the launcher properties. However the last two options are rather dances around the fire to summon spirits. The first suggestion should work 100%.
Make sure the error we are solving is something like: "Unable to locate plugin bla bla" in the error log.
All the best.

Eclipse run old version of program

I have a problem while runing my application in eclipse. I make some edits like this:
String res = "newvalue";
System.out.println(res);
But when I run the application I still receive "oldvalue" in output. After this I tried to delete main() function - and I run application and I see "oldvalue" in output again.
Maybe it's some cache in JVM, or smth. else?
UPD:
It's 15:35 on my clock now. But in /bin folder I see .class files with 14:33 timestamp. I change source files (.java), press ctrl+f11 in eclipse and files in /bin folder are still 14:33 ...
UPD2:
After cleaning the project I receive the following problem:
The project was not built due to "Could not write file: D:\projects\NelderMead\bin\ru.". Fix the problem, then try refreshing this project and building it since it may be inconsistent
SOLUTION
The problem was that eclipse can't write file to the folder with spaces and UTF chars in it's name. So, I copy project to the new clean workspace and it runs without problems! Thx all for help detecting the problem!
You're executing an older class files, the reason could be
a compile error somewhere else (see problems view)
or your changed accidentally the source path so that the new source no longer gets compiled.
Try to clean the project and make sure the new classes are compiled to your output folder.
The JVM doesn't have a cache for class files.
First, make sure the file is saved (there is no asterisk next to the file name in the tab). Usually files are saved automatically, but you could choose not to save files and never ask by mistake, the first time Eclipse pops up this dialog.
Then see what's going on in the Problems view. You might see something like project cannot be built due to the following reason. It may be because of compilation errors in the dependent projects.

Categories