JDK problems - Unable to load class files - windows-xp

Ok, so. I ordered a book on Java (Sams teach yourself java in 21 days) a week ago, and it came in just yesterday. I am working on the first example code, and I keep getting this error when I try to compile the main code:
C:\VolcanoApplication.java:5: error: cannot find symbol
VolcanoRobot dante = new VolcanoRobot();
^
symbol: class VolcanoRobot
location: class VolcanoApplication
C:\VolcanoApplication.java:5: error: cannot find symbol
VolcanoRobot dante = new VolcanoRobot();
^
symbol: class VolcanoRobot
location: class VolcanoApplication
And the main code Im trying to compile is:
public class VolcanoApplication
{
public static void main(String[] arguments)
{
VolcanoRobot dante = new VolcanoRobot();
dante.status = "exploring";
dante.speed = 2;
dante.temperature = 510;
dante.showAttributes();
System.out.println("Increasting speed to 3.");
dante.speed = 3;
dante.showAttributes();
System.out.println("Changing temperature to 670.");
dante.temperature = 670;
dante.showAttributes();
System.out.println("Checking the temperature.");
dante.checkTemperature();
dante.showAttributes();
}
}
and the VolcanoRobot.java file:
public class VolcanoRobot
{
String status;
int speed;
float temperature;
void checkTemperature()
{
if(temperature > 660)
{
status = "returning home";
speed = 5;
}
}
void showAttributes()
{
System.out.println("Status: " + status);
System.out.println("Speed: " + speed);
System.out.println("Temperature: " + temperature);
}
}
I am unable to get javac to run anywhere in command prompt (I'm running xp) so I navigate to where my javac.exe is (C:\Program Files\Java\jdk1.7.0_03\bin) and compile VolcanoApplication from there (VolcanoApplication is found on the root of C:)
When I just type Java anywhere I get the menu, but not javac. I declared the path and classpath variables, and yet it doesn't work. any suggestions?

Your best bet is to make javac work from any directory by going into the environment variables and changing your PATH so it includes C:\Program Files\jdk1.7.0_03\bin.
Once you've done that, in a command prompt typing javac anywhere should work.
The reason javac isn't finding the VolcanoRobot.java file is that it's not in the path that javac searches for source files. By default, that path includes the current directory, so if you cd to the directory containing VolcanoApplication.java and VolcanoRobot.java, then
javac VolcanoRobot.java VolcanoApplication.java
...should do it. If it doesn't, add -cp .:
javac -cp . VolcanoRobot.java VolcanoApplication.java
You should then be able to run it via
java VolcanoApplication
...or
java -cp . VolcanoApplication
Update: Since my main workstation is Linux-based, I hadn't done this under Windows 7 (used to do it all the time with Windows XP) and so I got to wondering whether there was something special about it. Doesn't look like there is. I installed the JDK on my Windows 7 box and didn't have any trouble using it. Here's exactly what I did:
Opened a command prompt and typed javac and pressed Enter, just to make sure I didn't have one installed I didn't remember. I got the usual "...is not recognized as an internal or external command" error.
Downloaded the JDK installer from Oracle.
Ran it, letting it install to its default location.
Opened the Control Panel.
Typed "environ" into the search box (because I'm lazy and don't bother to keep track of where they've moved it to this week).
Clicked the "Edit system environment variables" choice and clicked Yes on the admin permissions pop-up question. This opened a "System Properties" dialog with the "Advanced" tab open.
Clicked the "Environment Variables..." button on that tab.
In the "System variables" box at the bottom, scrolled down to Path.
With that highlighted, clicked the "Edit..." button, which opened the "Edit System Variable" box.
In Windows Explorer, navigated to the JDK's bin directory, which was at C:\Program Files\Java\jdk1.7.0_03\bin.
Clicked in the address bar, selected all, and copied that path to the clipboard.
Back in the "Edit System Variable" box, I put the cursor at the end of the path, typed a semicolon (;) (note: not a colon, and with no spaces around it), and then pasted the path from the clipboard.
Clicked the OK button on that box, the OK button on the "Environment Variables" box, and the OK button on the "System Properties" box.
Opened a new commmand prompt.
Typed javac and pressed Enter. I got the javac help listing.
Created the two volcano source files and put them in a directory (in my case, C:\tmp\j).
Changed into that directory.
Typed:
javac VolcanoRobot.java VolcanoApplication.java
...and pressed Enter. I got no errors.
Typed:
java VolcanoApplication
...and pressed Enter. It worked just fine, I got the output I'd expect from looking at the source files.
So there's no problem doing this on Windows 7. Perhaps what I did above will be helpful to you.

If the C:\Program Files\Java\jdk1.7.0_03\bin folder is entered into your system path environment variable, you might need to reopen cmd.exe, as it will not load these environment variables on the fly.
You then need to run javac from the root of your application.

Related

C/C++ debugger failing to create and write to raise.c in WSL using VSCode

I am trying to develop in C on WSL(2) (using Ubuntu) for a university course but am having trouble using the built in debugger for C/C++ in VSCode (installed via the C/C++ extension.
For my testings, I am running this code:
#include <assert.h>
int main() {
assert(1==0);
return 0;
}
When running into the assert, the debugger errors and VSC displays the following message on the bottom right corner:
Unable to open 'raise.c': Unable to read file 'vscode-remote://wsl+ubuntu/build/glibc-eX1tMB/glibc-2.31/sysdeps/unix/sysv/linux/raise.c' (Error: Unable to resolve non-existing file 'vscode-remote://wsl+ubuntu/build/glibc-eX1tMB/glibc-2.31/sysdeps/unix/sysv/linux/raise.c').
I have tried every single tutorial, github issue and stackoverflow question's answer but nothing has worked.
I have reason to believe that this has to do with VSC not having some kind of permissions to write/create files because if I press on Create File (which is prompted in the message), It says:
Unable to write file 'vscode-remote://wsl+ubuntu/build/glibc-eX1tMB/glibc-2.31/sysdeps/unix/sysv/linux/raise.c' (NoPermissions (FileSystemError): Error: EACCES: permission denied, mkdir '/build')
but, if I create the folder /build and chmod 777 it, it is able to create the file, but not write anything into it.
Does anyone have a method to solve this?
Also, what is raise.c and why do I need it anyways?
According to the GDB skip function:https://sourceware.org/gdb/onlinedocs/gdb/Skipping-Over-Functions-and-Files.html#Skipping-Over-Functions-and-FilesPuede add it to "SetupCommands" under "configurations" in Launch.json:
{
"description": "Skip glibc files",
"text": "-interpreter-exec console \"skip -gfi build/glibc-YYA7BZ/glibc-2.31//**/*\""
}
But no problem, add WSL + Ubuntu / or VSL + ubuntu, it will ignore the path, it does not solve the problem, which may be valid for other environments, but it is not valid if VSCode uses remote connection. According to article number 811:Disable "Unable to open file" during debugThe developers say that the "Skip" command is also looking online, currently (January 27, 2019) I do not know of any other way. But there are other solutions under this issue, no need to compile Glibc library:
Execute this:
$ sudo apt install glibc-source
$ cd /usr/src/glibc
$ sudo tar xvf glibc-2.31.tar.xz
The "2.31" should be changed to the actual version number Source, and can be seen through the "LS" command. Then add that in "settings" in Launch.json
"sourceFileMap": {
"/build/glibc-YYA7BZ": "/usr/src/glibc"
}
The "YYA7BZ" is changed to the GLIBC suffix appears in the error message. If this method is not valid, you can change the path to: c:/users//AppData/ / / /local packages canonicalGroupLimited.ubuntuonWindows_79RHKP1FNDGSC / /localstate / / rootfs usr/src/glibc, where 79RHKP1FNDGSC should change the folder name on your own system.
Now searching for terminal error information:
Done "/usr/bin/gdb" --interpreter=mi --tty=${DbgTerm} 0<"/tmp/Microsoft-MIEngine-In-p3q623bu.gbr" 1>"/tmp/Microsoft-MIEngine-Out-s4xm3p6g.lqk"
according to the error when executing: ends Call After launching an instance of 'std :: logic_error'This is caused by an empty pointer. One of the possible causes of this problem is that I forgot to add the necessary parameters to add a run program in the "Args" list in "Configurations" in Launch.json.
Source:https://programmerclick.com/article/54012533450/
See this procedure, similar error but in different environment.
https://stackoverflow.com/a/48287761/16842210
In my case, I used try{}catch{} to print the error and saw what was, had nothing to do with raise.c

How can I get Compass to work in Visual Studio via NuGet?

My developer friend who has the luxury of developing in a non-Windows environment has been raving about Compass. I finally decided I wanted to give it a try. I'm tired of trying to keep up with all of the intricacies of cross-browser CSS.
So, I found it on NuGet, and installed it.
I installs to my solutions root directory in the packages directory:
$(SolutionDir)packages\Ruby.Compass.0.12.2.3\
It comes with a Readme that states the following message:
Ruby Compass v. 0.12.2
Compass is installed in its own NuGet package dir, and available by
'compass' command in "packages\Ruby.Compass.0.12.2.3" folder.
To compile Compass files during build, add the next line to the
project pre-build events:
"$(SolutionDir)packages\Ruby.Compass.0.12.2.3\compass" compile
"$(ProjectDir)."
So, I placed the line in my pre-build events, saved, and tried to build my project. However, I get an error as follows:
The command
""$(SolutionDir)packages\Ruby.Compass.0.12.2.3\compass" compile "$(ProjectDir)."" exited with code 1.
Notice: It actually shows the full path to the ProjectDir and SolutionDir as it's supposed too in the error message. I replaced them with the tokens to keep the project name unanimous.
Let me mention that I tried variations of the suggestion pre-build line:
"$(SolutionDir)packages\Ruby.Compass.0.12.2.3\compass" compile "$(ProjectDir)"
"$(SolutionDir)packages\Ruby.Compass.0.12.2.3\compass" compile "$(ProjectDir)css"
"$(SolutionDir)packages\Ruby.Compass.0.12.2.3\compass" compile "$(ProjectDir)css\test.scss"
The first one just removed that trailing .. The second one pointed it to the directory where all my css files are stored. The third one pointed it to the exact file I was trying to compile was located.
I opened up compass.cmd which is the file it is calling, and it looks like the following:
#echo off
"%~dp0ruby\bin\compass" %*
I'm assuming this calls the compass file in the ruby/bin folder, which looks like this:
#!C:/downloads/ruby-2.0.0-p247-x64-mingw32/ruby-2.0.0-p247-x64-mingw32/bin/ruby.exe
#
# This file was generated by RubyGems.
#
# The application 'compass' is installed as part of a gem, and
# this file is here to facilitate running it.
#
require 'rubygems'
version = ">= 0"
if ARGV.first
str = ARGV.first
str = str.dup.force_encoding("BINARY") if str.respond_to? :force_encoding
if str =~ /\A_(.*)_\z/
version = $1
ARGV.shift
end
end
gem 'compass', version
load Gem.bin_path('compass', 'compass', version)
From there, I'm not sure what is going on. I'm not a Ruby person.
Is there an issue that I'm overlooking here?
Has anyone else been able to install Ruby.Compass via NuGet?
How can I get this working in Visual Studio without having to fight with Ruby?
From: http://codewith.us/automating-css-generation-in-visual-studio-using-sasscompass/
"Note that, if there are issues with your SCSS files, you will receive some variation of the error below.
Error 36 The command "del "C:Projectspubliccss*.css" /S
compass compile "C:Projectspublic" --force" exited with code 1.
Open your Output window (click View -> Output or press Ctrl+W, O), and select “Build” in the “Show output from:” menu. Scroll up until you find your command in the log and you should get a little more insight into what portion of the command failed."

Compiling android native app calling ndk-build from eclipse, on ubuntu

On ubuntu 11.10 I installed eclipse from repositories, installed adt and cdt plugins. I am able to compile the hello-jni example using command line, but i would like to use eclipse for the task.
I followed the guide here: http://mhandroid.wordpress.com/2011/01/23/using-eclipse-for-android-cc-development/ and defined a PATH variable in eclipse preferences (window->preferences->c/c++->environment), pointing to the ndk-r7b folder. But the project won't buid. I get this error:
(Cannot run program "ndk-build"
(in directory "/home/athos/android/ndk-r7b/samples/hello-jni"):
java.io.IOException:
error=2, File o directory non esistente)
(last line should be "no such file or directory" in english)
If I specify "${PATH}/ndk-build" or "/home/athos/android/ndk-r7b/ndk-build" as the build command. i get this:
/home/lavoro/android/ndk-r7b/ndk-build
ERROR: Cannot find 'make' program. Please install Cygwin make package
/home/lavoro/android/ndk-r7b/ndk-build: 40: dirname: not found
or define the GNUMAKE variable to point to it.
If I define the GNUMAKE variable in window->preferences->c/c++->environment i get this:
ERROR: Your GNUMAKE variable is defined to an invalid name: /usr/bin/make
Please fix it to point to a valid make executable (e.g. /usr/bin/make)
Which is funny, since It suggests the exact same directory I indicated. Make is installed and present at the indicated location.
What am I missing?
It's a bit ugly, but you can always put
/fully/qualified/path/to/ndk-build
In your build command.

Eclipse Indigo CDT: Function could not be resolved

This feels silly, but its been 2 days...somewhere after upgrading from Ubuntu 10.04 to 10.11 and from Eclipse Helios to Eclipse Indigo, I got stuck with the following problem:
Problem Description:
I'm trying to use a function in math.h called isinf(), but the problem also occurs with things like isnan(). The program compiles fine on the command line using make and fine in eclipse using build. But if I open the program file in eclipse it reports that it cannot reolve the isinf() function call. If I just insert the program contents into a new project and new source file, the error appears immediately. This problem did not occur under 11.04 with Eclipse Helios CDT
Questions:
Why are these errors only reported when the program file is opened and not on when the program is compiled; why are the errors not detected make is run from the command line? Is there a solution/workaround available?
Version Info
Linux Ubuntu 10.11 64-bit
Eclipse CDT Indigo, Service Release 1, Build id: 20110916-0149
(Also using Eclipse EE Indigo – if that makes a difference)
GNU Make 3.81
gcc 4.6.1-9Ubuntu3
To Duplicate:
Please find the two files you'll need to replicate below:
Step 0. Verify that everything is fine outside of Eclipse
Copy the attached source file and make file
create a directory e.g. Mkdir FunTest
Save the source file a 'Test.cpp' and the makefile as 'makefile'
Open a command prompt and navigate to the directory e.g. FunTest
Enter 'make'
Enter ./TestOut
Program responds “is not infinite”
Step 1. Create the project in Eclipse
Open Eclipse
Select File|New|MakeFile Project with Existing Code
Click Browse – navigate to the directory (FunTest) and click ok
Select 'Linux GCC' from the Toolchain selector
Click Finish
Step 2. Find the Error
Click Build All (Ctrl-B) – project builds without errors
Open the project in the project explorer to display the file in the directory
Double click on the file “Test.cpp”
Note the error icon next to line testing for infinity
Note the 2 error messages:
Semantic error: Function _isinff could not be resolved
Semantic error: Function _isinfl could not be resolved
Test.cpp:
include <math.h>
int main(int argc, char **argv)
{
int TestNum = 10;
if (isinf(TestNum) == 0)
printf("Not infinite\n");
return 0;
}
makefile:
# Specify the compiler
CC = g++
# Specify the compiler flags
CFLAGS += -c
# Specify the files making up the application
SOURCES = Test.cpp
OBJECTS = $(SOURCES:.cpp=.o)
EXECUTABLE = TestOut
all: $(EXECUTABLE)
$(EXECUTABLE): $(OBJECTS)
$(CC) $(LDFLAGS) $(OBJECTS) $(LDLIBS) -o $#
.cpp.o:
$(CC) $(CPPFLAGS) $(CFLAGS) $< -o $#
install:
#echo "Build complete!"
I have experienced similar problems of the CDT reporting errors even though the code compiled fine within Eclipse Indigo.
Project > Properties > Settings > Binary Parsers > "GNU Elf Parser"
helped in my case. I had the "Elf Parser" checked.
That looks like a problem that many others have had with eclipse CDT before. Sometimes shutting eclipse down and then starting it back up again is enough to help. If that isn't the case, take a look at what I have below:
Compilation ok, but eclipse content assist having problems
Check your includes: if you're using include<math.h> change it to include<cmath>. The same for stdio.h and stdlib.h, you should replace by cstdio and cstdlib. Another option may be change you project to a C project instead of a C++.
You are missing -lm option in your build preferences.
Project->Properties->Settings->Miscleanous->Other (linker) flags[]
For me, it was solved by adding a specific ‘Source Location’ folder, and removing the default. In Luna, it is under:
Project > Properties > C/C++ General > Paths and Symbols > Source
Location

re: Java package declaration: Netbeans says: ‘Incorrect Package’

orig post:
Hello List,
I am new to Java, Netbeans, and the IB Java API.
I downloaded the IB Java API software and I am using Netbeans to look at it.
On one of the files, Netbeans is indicating a problem with the file.
At the very top of the file, the author has placed a package declaration:
package samples.rfq;
Netbeans is using a red-dot to the left of the package declaration to tell me that it has a problem with the package declaration.
When I mouse-hover the package declaration, Netbeans tells me this:
Incorrect Package (Alt-Enter shows hints)
On my Mac-keyboard I press Alt-Enter and Netbeans just interprets that as an Enter (and then I need to undo that Enter).
I have 2 questions:
How do I work around the Alt-Enter-bug to see the hints?
What do you typically do when Netbeans indicates 'Incorrect Package' on one of your package declarations?
My comment to Josefx:
josefx,
I think maybe you gave me a good clue.
I looked at the file and I see it here in the (Linux) file system:
a#z2:/pt/z2/api$
a#z2:/pt/z2/api$ ls -la /pt/z2/api/samples/rfq/SampleRfq.java
-rw-r--r-- 1 a a 14475 2008-08-13 15:49 /pt/z2/api/samples/rfq/SampleRfq.java
a#z2:/pt/z2/api$
a#z2:/pt/z2/api$
a#z2:/pt/z2/api$
a#z2:/pt/z2/api$ grep package /pt/z2/api/samples/rfq/SampleRfq.java
package samples.rfq;
a#z2:/pt/z2/api$
So obviously it is in a directory which matches its package declaration.
I tried running javac against the file from a variety of directories.
This works:
cd /pt/z2/api/
javac samples/rfq/SampleRfq.java
If I run javac from any other directory it fails.
So, I see a dependency between 3 things here:
Location of the SampleRfq.java
Syntax in the package declaration
Location of the javac command
Since I got javac to work, I'm convinced of 2 things:
SampleRfq.java is in the correct directory
Syntax in the package declaration is correct
So, it looks like my issue is with Netbeans.
Netbeans is too ... 'stupid' to know that:
SampleRfq.java is in the correct directory
Syntax in the package declaration is correct
How do I help Netbeans?
I posted a question to the Netbeans mail-list and the only answer I got was: "Fix the incorrect file name".
ok,
I got the error to evaporate.
steps:
abandon my netbeans project
rsync my code to a new directory; create new NB project; (NB will not let me use old code)
right-click-project: select properties
Add folder
Pick the parent of the directory corresponding to the package
Netbeans now "knows" that the package declaration matches the directory structure.