How to fix “Unresolved compilation problems: The type String is not visible” error in VSCode (Java)
I am writing a program in Java, and am getting the error message "Exception in thread "main" java.lang.Error: Unresolved compilation problems: The type String is not visible."
The program is running in VSCode, with Java 11. The program worked when it was running in eclipse, and when it was running in intellij. This error has occurred for all inputs I have tested (for example, "methane").
scanner class:
package setupbiomolecule;
import setupbiomolecule.*;
import java.util.Scanner;
public class ScannerClass {
public static String understoodMolecules() {
return "alkane, alkene, alkyne, carboxilic acid, ester, ketone, amine, amide, ether, aldehyde or alcohol. ";
}
public static String errorMessage() {
return "Error! You have either mispelled your molecule, not used standard nomenclature (http://www.chem.uiuc.edu/GenChemReferences/nomenclature_rules.html), or input a molecule that is not an" + ScannerClass.understoodMolecules() + "Also, it can't have more than 10 carbons";
}
public static void main(String args) {
Scanner scan = new Scanner(System.in);
String moleculeName = "";
System.out.println("Enter any " + understoodMolecules() + "with 10 or fewer carbons. nIt MUST be in IUPAC standard nomenclature!! nThis program will tell you the formula! Type 'stop' to stop.");
while(!moleculeName.equals("stop")) {
System.out.println("What is your Biomolecule?");
moleculeName = scan.nextLine().toLowerCase();
System.out.println(FunctionalGroupIdentifier.identifyType(moleculeName));
}
scan.close();
}
}
part of the functional group identifier:
package setupbiomolecule;
import functionalgroups.*;
public class FunctionalGroupIdentifier {
public static String identifyType(String molecule) {
String stringToReturn = null;
if(molecule.endsWith("ane")) {
stringToReturn = Alkanes.go(molecule);
}
return stringToReturn;
}
}
alkane class:
package functionalgroups;
import setupbiomolecule.PrefixToCarbon;
public class Alkanes {
public static String go(String molecule) {
int carbons = 0;
int endOfCarbons = molecule.indexOf("ane");
String carbonPrefix = molecule.substring(0, endOfCarbons);
carbons = PrefixToCarbon.prefixToCarbon(carbonPrefix);
int hydrogens = carbons*2+2;
String formula = "C"+ carbons + "H"+ hydrogens;
return formula;
}
}
The program is intended to output the formula for the molecule (methane would be CH4).
The error message in full is:
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
The type String is not visible
The type String is not visible
at functionalgroups.Alkanes.go(Alkanes.java:6) at >setupbiomolecule.FunctionalGroupIdentifier.identifyType(FunctionalGroupIdentifier.java:16)
at setupbiomolecule.ScannerClass.main(ScannerClass.java:19)
Daniel:biomoleculeApp mirawelner$
Any and all help appreciated! Thanks so much!
java visual-studio-code
add a comment |
I am writing a program in Java, and am getting the error message "Exception in thread "main" java.lang.Error: Unresolved compilation problems: The type String is not visible."
The program is running in VSCode, with Java 11. The program worked when it was running in eclipse, and when it was running in intellij. This error has occurred for all inputs I have tested (for example, "methane").
scanner class:
package setupbiomolecule;
import setupbiomolecule.*;
import java.util.Scanner;
public class ScannerClass {
public static String understoodMolecules() {
return "alkane, alkene, alkyne, carboxilic acid, ester, ketone, amine, amide, ether, aldehyde or alcohol. ";
}
public static String errorMessage() {
return "Error! You have either mispelled your molecule, not used standard nomenclature (http://www.chem.uiuc.edu/GenChemReferences/nomenclature_rules.html), or input a molecule that is not an" + ScannerClass.understoodMolecules() + "Also, it can't have more than 10 carbons";
}
public static void main(String args) {
Scanner scan = new Scanner(System.in);
String moleculeName = "";
System.out.println("Enter any " + understoodMolecules() + "with 10 or fewer carbons. nIt MUST be in IUPAC standard nomenclature!! nThis program will tell you the formula! Type 'stop' to stop.");
while(!moleculeName.equals("stop")) {
System.out.println("What is your Biomolecule?");
moleculeName = scan.nextLine().toLowerCase();
System.out.println(FunctionalGroupIdentifier.identifyType(moleculeName));
}
scan.close();
}
}
part of the functional group identifier:
package setupbiomolecule;
import functionalgroups.*;
public class FunctionalGroupIdentifier {
public static String identifyType(String molecule) {
String stringToReturn = null;
if(molecule.endsWith("ane")) {
stringToReturn = Alkanes.go(molecule);
}
return stringToReturn;
}
}
alkane class:
package functionalgroups;
import setupbiomolecule.PrefixToCarbon;
public class Alkanes {
public static String go(String molecule) {
int carbons = 0;
int endOfCarbons = molecule.indexOf("ane");
String carbonPrefix = molecule.substring(0, endOfCarbons);
carbons = PrefixToCarbon.prefixToCarbon(carbonPrefix);
int hydrogens = carbons*2+2;
String formula = "C"+ carbons + "H"+ hydrogens;
return formula;
}
}
The program is intended to output the formula for the molecule (methane would be CH4).
The error message in full is:
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
The type String is not visible
The type String is not visible
at functionalgroups.Alkanes.go(Alkanes.java:6) at >setupbiomolecule.FunctionalGroupIdentifier.identifyType(FunctionalGroupIdentifier.java:16)
at setupbiomolecule.ScannerClass.main(ScannerClass.java:19)
Daniel:biomoleculeApp mirawelner$
Any and all help appreciated! Thanks so much!
java visual-studio-code
1
You have not included your fullFunctionalGroupIdentifier
class. I hope you are returning theString
stringToReturn
in theidentifyType
method.
– Nikhil
Jan 1 at 8:32
1
Also please show the full error stack trace.
– Nikhil
Jan 1 at 8:35
1
In the packagesetupbiomolecules
, you shouldn't importsetupbiomolecules.*
- all the types in the current package are available directly and don't need to be imported. As for your problem, check if you don't have a type or interface namedString
somewhere in your packages.
– RealSkeptic
Jan 1 at 9:16
add a comment |
I am writing a program in Java, and am getting the error message "Exception in thread "main" java.lang.Error: Unresolved compilation problems: The type String is not visible."
The program is running in VSCode, with Java 11. The program worked when it was running in eclipse, and when it was running in intellij. This error has occurred for all inputs I have tested (for example, "methane").
scanner class:
package setupbiomolecule;
import setupbiomolecule.*;
import java.util.Scanner;
public class ScannerClass {
public static String understoodMolecules() {
return "alkane, alkene, alkyne, carboxilic acid, ester, ketone, amine, amide, ether, aldehyde or alcohol. ";
}
public static String errorMessage() {
return "Error! You have either mispelled your molecule, not used standard nomenclature (http://www.chem.uiuc.edu/GenChemReferences/nomenclature_rules.html), or input a molecule that is not an" + ScannerClass.understoodMolecules() + "Also, it can't have more than 10 carbons";
}
public static void main(String args) {
Scanner scan = new Scanner(System.in);
String moleculeName = "";
System.out.println("Enter any " + understoodMolecules() + "with 10 or fewer carbons. nIt MUST be in IUPAC standard nomenclature!! nThis program will tell you the formula! Type 'stop' to stop.");
while(!moleculeName.equals("stop")) {
System.out.println("What is your Biomolecule?");
moleculeName = scan.nextLine().toLowerCase();
System.out.println(FunctionalGroupIdentifier.identifyType(moleculeName));
}
scan.close();
}
}
part of the functional group identifier:
package setupbiomolecule;
import functionalgroups.*;
public class FunctionalGroupIdentifier {
public static String identifyType(String molecule) {
String stringToReturn = null;
if(molecule.endsWith("ane")) {
stringToReturn = Alkanes.go(molecule);
}
return stringToReturn;
}
}
alkane class:
package functionalgroups;
import setupbiomolecule.PrefixToCarbon;
public class Alkanes {
public static String go(String molecule) {
int carbons = 0;
int endOfCarbons = molecule.indexOf("ane");
String carbonPrefix = molecule.substring(0, endOfCarbons);
carbons = PrefixToCarbon.prefixToCarbon(carbonPrefix);
int hydrogens = carbons*2+2;
String formula = "C"+ carbons + "H"+ hydrogens;
return formula;
}
}
The program is intended to output the formula for the molecule (methane would be CH4).
The error message in full is:
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
The type String is not visible
The type String is not visible
at functionalgroups.Alkanes.go(Alkanes.java:6) at >setupbiomolecule.FunctionalGroupIdentifier.identifyType(FunctionalGroupIdentifier.java:16)
at setupbiomolecule.ScannerClass.main(ScannerClass.java:19)
Daniel:biomoleculeApp mirawelner$
Any and all help appreciated! Thanks so much!
java visual-studio-code
I am writing a program in Java, and am getting the error message "Exception in thread "main" java.lang.Error: Unresolved compilation problems: The type String is not visible."
The program is running in VSCode, with Java 11. The program worked when it was running in eclipse, and when it was running in intellij. This error has occurred for all inputs I have tested (for example, "methane").
scanner class:
package setupbiomolecule;
import setupbiomolecule.*;
import java.util.Scanner;
public class ScannerClass {
public static String understoodMolecules() {
return "alkane, alkene, alkyne, carboxilic acid, ester, ketone, amine, amide, ether, aldehyde or alcohol. ";
}
public static String errorMessage() {
return "Error! You have either mispelled your molecule, not used standard nomenclature (http://www.chem.uiuc.edu/GenChemReferences/nomenclature_rules.html), or input a molecule that is not an" + ScannerClass.understoodMolecules() + "Also, it can't have more than 10 carbons";
}
public static void main(String args) {
Scanner scan = new Scanner(System.in);
String moleculeName = "";
System.out.println("Enter any " + understoodMolecules() + "with 10 or fewer carbons. nIt MUST be in IUPAC standard nomenclature!! nThis program will tell you the formula! Type 'stop' to stop.");
while(!moleculeName.equals("stop")) {
System.out.println("What is your Biomolecule?");
moleculeName = scan.nextLine().toLowerCase();
System.out.println(FunctionalGroupIdentifier.identifyType(moleculeName));
}
scan.close();
}
}
part of the functional group identifier:
package setupbiomolecule;
import functionalgroups.*;
public class FunctionalGroupIdentifier {
public static String identifyType(String molecule) {
String stringToReturn = null;
if(molecule.endsWith("ane")) {
stringToReturn = Alkanes.go(molecule);
}
return stringToReturn;
}
}
alkane class:
package functionalgroups;
import setupbiomolecule.PrefixToCarbon;
public class Alkanes {
public static String go(String molecule) {
int carbons = 0;
int endOfCarbons = molecule.indexOf("ane");
String carbonPrefix = molecule.substring(0, endOfCarbons);
carbons = PrefixToCarbon.prefixToCarbon(carbonPrefix);
int hydrogens = carbons*2+2;
String formula = "C"+ carbons + "H"+ hydrogens;
return formula;
}
}
The program is intended to output the formula for the molecule (methane would be CH4).
The error message in full is:
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
The type String is not visible
The type String is not visible
at functionalgroups.Alkanes.go(Alkanes.java:6) at >setupbiomolecule.FunctionalGroupIdentifier.identifyType(FunctionalGroupIdentifier.java:16)
at setupbiomolecule.ScannerClass.main(ScannerClass.java:19)
Daniel:biomoleculeApp mirawelner$
Any and all help appreciated! Thanks so much!
java visual-studio-code
java visual-studio-code
edited Jan 1 at 21:25
Christopher Connery
asked Jan 1 at 8:11
Christopher ConneryChristopher Connery
9617
9617
1
You have not included your fullFunctionalGroupIdentifier
class. I hope you are returning theString
stringToReturn
in theidentifyType
method.
– Nikhil
Jan 1 at 8:32
1
Also please show the full error stack trace.
– Nikhil
Jan 1 at 8:35
1
In the packagesetupbiomolecules
, you shouldn't importsetupbiomolecules.*
- all the types in the current package are available directly and don't need to be imported. As for your problem, check if you don't have a type or interface namedString
somewhere in your packages.
– RealSkeptic
Jan 1 at 9:16
add a comment |
1
You have not included your fullFunctionalGroupIdentifier
class. I hope you are returning theString
stringToReturn
in theidentifyType
method.
– Nikhil
Jan 1 at 8:32
1
Also please show the full error stack trace.
– Nikhil
Jan 1 at 8:35
1
In the packagesetupbiomolecules
, you shouldn't importsetupbiomolecules.*
- all the types in the current package are available directly and don't need to be imported. As for your problem, check if you don't have a type or interface namedString
somewhere in your packages.
– RealSkeptic
Jan 1 at 9:16
1
1
You have not included your full
FunctionalGroupIdentifier
class. I hope you are returning the String
stringToReturn
in the identifyType
method.– Nikhil
Jan 1 at 8:32
You have not included your full
FunctionalGroupIdentifier
class. I hope you are returning the String
stringToReturn
in the identifyType
method.– Nikhil
Jan 1 at 8:32
1
1
Also please show the full error stack trace.
– Nikhil
Jan 1 at 8:35
Also please show the full error stack trace.
– Nikhil
Jan 1 at 8:35
1
1
In the package
setupbiomolecules
, you shouldn't import setupbiomolecules.*
- all the types in the current package are available directly and don't need to be imported. As for your problem, check if you don't have a type or interface named String
somewhere in your packages.– RealSkeptic
Jan 1 at 9:16
In the package
setupbiomolecules
, you shouldn't import setupbiomolecules.*
- all the types in the current package are available directly and don't need to be imported. As for your problem, check if you don't have a type or interface named String
somewhere in your packages.– RealSkeptic
Jan 1 at 9:16
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53993977%2fhow-to-fix-unresolved-compilation-problems-the-type-string-is-not-visible-err%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53993977%2fhow-to-fix-unresolved-compilation-problems-the-type-string-is-not-visible-err%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
You have not included your full
FunctionalGroupIdentifier
class. I hope you are returning theString
stringToReturn
in theidentifyType
method.– Nikhil
Jan 1 at 8:32
1
Also please show the full error stack trace.
– Nikhil
Jan 1 at 8:35
1
In the package
setupbiomolecules
, you shouldn't importsetupbiomolecules.*
- all the types in the current package are available directly and don't need to be imported. As for your problem, check if you don't have a type or interface namedString
somewhere in your packages.– RealSkeptic
Jan 1 at 9:16