Questions tagged [java.lang.class]

Java.lang.class is a runtime representation of classes and interfaces.

97 questions
1
vote
3 answers

java.lang.NullPointerException form user input

Hey guys I'm trying to create a loop until a correct character choice is entered by the user. When I enter a wrong choice I get the error java.lang.NullPointerException. It might be with the way I'm inputing but I don't want to change that if I…
KingKrypton
  • 65
  • 1
  • 1
  • 5
1
vote
2 answers

HiveServer Class Not Found Exception

I'm trying to run hive from the command prompt it is working absolutely fine. But when I try running hiveserver using "hive --service hiveserver" command, I'm getting the following exception. Starting Hive Thrift Server Exception in thread "main"…
1
vote
1 answer

Collection of classes which implement a certain interface

I'm stuggling for some hours with this problem and I hope that you can help me out. I have a interface which defines some methods: public interface LanguageInterface { //... } There is a class which implement the LanguageInterface public…
1
vote
4 answers

Can't return a Object[] casted as String[]

public String[] getAllKeys (){ Object[] keysCopy = new Object[keys.size()]; keysCopy = keys.toArray(); return ((String[])keysCopy()); } Why this gives me Ljava.lang.Object; cannot be cast to [Ljava.lang.String??
user2911701
  • 69
  • 1
  • 10
1
vote
1 answer

Get java.lang.Class object of a class by reading its source(.java) file

I want to get the java.lang.Class object of a class by reading its source file using FileReader. Actually I want to get all methods, constructors, parent class, overridden methods and imported packages of the class by selecting its source file using…
earthmover
  • 4,395
  • 10
  • 43
  • 74
1
vote
2 answers

Try catch is not catching a bad number input ( Also getting a java.lang.arithmatic exception / zero)

This is a Constructor that I have for a test average class. My assignment asks me to bring in an array-list of test score and as input validation, it wants me to use a try catch statement to catch any input under 0 and over 100. The constructor…
Erick
  • 19
  • 1
  • 7
1
vote
1 answer

XML worker using itext

import java.io.FileOutputStream; import java.io.StringReader; import com.itextpdf.text.Document; import com.itextpdf.text.PageSize; import com.itextpdf.text.pdf.PdfWriter; import com.itextpdf.tool.xml.XMLWorkerHelper; public class HtmlToPDF2 { …
Standin.Wolf
  • 1,224
  • 1
  • 10
  • 32
1
vote
3 answers

How would i fix this Error java.lang.Object[] cannot be cast to java.lang.String[]?

Im not to sure how to fix this since my code is String[] and not Object[] How would i go about fixing this error? Here is s the full logcat: 06-14 00:25:40.356: W/dalvikvm(13023): threadid=1: thread exiting with uncaught exception…
Dakota Miller
  • 493
  • 1
  • 4
  • 22
1
vote
1 answer

main(java.lang.String) already declared in main(String args[]) error displayed

When I compile the following code it shows this error: main(java.lang.String) already declared in main(String args[]) public static void main(String[] args) { Scanner sc = new Scanner(System.in); int[] array1 = new int[10]; for (int i =…
Kumar_diru
  • 121
  • 9
1
vote
4 answers

Is Class immutable in Java, also known as, is Class a safe key for HashMap?

I have been lurking the net for a while now, but haven't found an answer to this yet. Someone is mentioning Class as key here on SO (I think) but I can't find the post anymore. In any case, this question deserves a proper answer (apologizing if…
1
vote
4 answers

Value in TextField throws java.lang.NumberFormatException error

So this is how I have my code (of course, not finished because I don't want to do any other work until I can figure out why I'm getting the error). It compiles no problem but when I try to run it I get a java.lang.NumberFormatException for my first…
1
vote
2 answers

How to get a form's data after the user submitted it with Spring MVC?

i am getting an error message: org.springframework.web.util.NestedServletException: Request processing failed; nested exception is java.lang.ClassCastException: java.lang.Object cannot be cast to com.crimetrack.business.Login Login.java public class…
devdar
  • 5,564
  • 28
  • 100
  • 153
1
vote
1 answer

PowerMock's mockStatic() overwrites X.class.y() methods

MyClass.java: package test; public final class MyClass { public MyClass() { } public Package returnPackage() { return MyClass.class.getPackage(); } } TestClass.java: package test; import org.junit.Test; import…
main--
  • 3,873
  • 1
  • 16
  • 37
1
vote
1 answer

Best way to send java.lang.Class via dispatch?

here's the setup: I'm using GWT 2.4 with gwt-platform 0.7. I have a bunch of classes that contain key-value-pairs (at the moment int->String). They are just different classes because they get saved to different tables in database via JPA. Now I'd…
Benjamin M
  • 23,599
  • 32
  • 121
  • 201
0
votes
2 answers

j2me function java.lang.nullpointerexception - what is wrong in this?

Yesterday Night, i wrote this function to fetch all the tags from string containing xml data but something is not correct in this... Pls help... this function is returning java.lang.NullPointerException public void parseWebXML(String xd){ …
Krishna
  • 165
  • 1
  • 12