Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 3 days ago.
Improve this question
I'm new at Java, and I'm practicing creating different classes within the same file, and them using them as objects. But when it compiled, it gives me an error on line 07. This is my code so far:
import java.util.Scanner;
package functions;
public class functions {
public static void main (String args[]) {
Scanner sc = new Scanner(System.in);
functions fun = new functions();
fun.Print("Hello World");
}
public void Print(String text) {
System.out.print(text);
}
}
The error in question is:
Exception in thread "main" java.lang.Error: Unresolved compilation
problem: at functions.functions.main
I've tried to delete any class that were not main, I've tried to create the file without a package.
The package declaration should come before the import.
Related
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 7 years ago.
Improve this question
I try this code and it works very well:
package code;
public class TestClass
{
public static String myName="محمد mohammed";
public static String getMyName()
{
return myName;
}
public static void main(String[] args)
{
System.out.println(getMyName());
}
}
and I get this result :
محمد mohammed
But when I try to call from servlet in same package and project :
protected void doGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException
{
...
System.out.println(TestClass.getMyName());
...
}// END DO GET
I got this result:
???? mohammed
Moreover, I tried to print directly from the servlet and I got '?' for any Arabic letter.
Note:
In two files I use : UTF-8
**
It is solved by changing server encoding. see below:
**
Go to (if use Eclipse):
1- Servers.
2- open the server.
3- find : open lunch configuration then open it.
4- Go to Common.
5- Change Encoding.
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 8 years ago.
Improve this question
This code works in Eclipse, but when I try to submit the 'Test' problem on the SPOJ site, it gives me a compilation error.
Can you please tell me why?
public class Test{
public static void main(String [] args)
{
java.util.Scanner input=new java.util.Scanner(System.in) ;
int n ;
while(true )
{
n =input.nextInt() ;
if(n==42)
break ;
else
System.out.println(n) ;
}
}
}
You have to name your class "Main" for it to work on SPOJ.
See this forum post for more information: https://www.spoj.com/forum/viewtopic.php?t=37
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
I keep getting this error:
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
at test.apples.main(apples.java:6)
My code is:
import java.util.Random;
class apples {
public static void main(String args[]) {
Random rand = new Random();
int freq[]=new int[7];
for(int roll=1;roll<1000;roll++) {
++freq[1+rand.nextInt(6)];
}
System.out.println("Face\tFrequency");
for(int face=1;face<freq.length;face++) {
System.out.println(face+"\t" +freq[face]);
}
}
}
You have to add package test; at the top of you class, then clean and rebuild your code.
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
getting two error when trying to compile programm using commandline
error-Shuffle1.java:24 error:package System does not exist
System.out.print("b c")
Shuffle1.java:31 error:package System does not exist
System.out.print("b c")
letter in word Sytem is also capital then too getting error
public class Shuffle1
{
public static void main(String[] args)
{
int x=3;
while(x > 0){
if(x > 2){
System.out.print("a");
}
x=x-1;
System.out.print("-");
if(x==2){
Sytem.out.print("b,c");
}
if(x==1){
Sytem.out.print("d");
x=x-1;
}
}
}
}
It is
System.out.print
NOT
Sytem.out.print
Cause you wrote Sytem instead System
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
my code is :
import ir.sbu.nlp.wordnet.data.model.FNSense;
import ir.sbu.nlp.wordnet.data.model.FNSynset;
import ir.sbu.nlp.wordnet.data.model.FNSynsetsRelation;
import ir.sbu.nlp.wordnet.service.FNSynsetService;
import java.util.Vector;
public class sample2 {
public static void main(String[] args) {
FNSynsetService service=new FNSynsetService();
service.findAll();
}
}
and when I run it display this error
Data Load Started...
Exception in thread "main" java.lang.NullPointerException
at ir.sbu.nlp.wordnet.data.dao.FNWordDao.getTextNode(FNWordDao.java:513)
at ir.sbu.nlp.wordnet.data.dao.FNWordDao.loadWords(FNWordDao.java:438)
at ir.sbu.nlp.wordnet.data.dao.FNWordDao.<init>(FNWordDao.java:76)
at ir.sbu.nlp.wordnet.data.dao.FNDaoManager.<init>(FNDaoManager.java:25)
at ir.sbu.nlp.wordnet.data.dao.FNDaoManager.getInstance(FNDaoManager.java:40)
at ir.sbu.nlp.wordnet.service.FNSynsetService.<init>(FNSynsetService.java:51)
at sample2.main(sample2.java:12)
Can every one help me?
I copy every file needed for installation
Seems like you need to set some object before calling service.findAll();
While this method is executing it might be trying to access some object which is turning out to be null. Debug and find out the exact line which is throwing NPE.