Error In Compiling Cryptic Java Code

May 21, 2015

I am getting a compile error message when I am trying to compile someone else code using Eclipse.  The partial code description is below as follows:
 
public String decrypt(String password) {
    try {
      // create the key and parameter spec
      KeySpec keySpec = new PBEKeySpec(password.toCharArray(), salt, interactions);
      SecretKey key = SecretKeyFactory.getInstance(keyFormat).generateSecret(keySpec);
      AlgorithmParameterSpec paramSpec = new PBEParameterSpec(salt, interactions);

[Code] ....

Below is the following error message:

Access restriction: The type 'BASE64Decoder" is not API (restriction on required library '/usr/lib64/jvm/java-1.8.0-openjdk-1.8.0/jre/lib/rd.jar')

How do I troubleshoot it?

View Replies


ADVERTISEMENT

Servlets :: No Error Shown While Compiling Java File But Also No Output

Jan 22, 2015

I made a web app to test the ServletContextListener in tomcat according to the book head first servlets and jsps and used the code

out.println("test context attributes set by listener<br>");
Dog dog = (Dog) getServletContext().getAttribute("dog");
out.println("Dog's breed is: "+dog.getBreed());

in the listener class.But the output is showing the first line only and the second println() is not showing any output whereas my Dog class compiled successfully and I didn't see any NullPointerException as expected in the book but somehow it seems like the problem is in the 2nd line of code only but I don't know what.

I also tried to add a 4th line at the end with println() only but with a simple text even that is not running but when I put that same line after the 1st line, the output is shown.I am unable to see what has gone wrong in the 2nd line of code.

View Replies View Related

Java Servlet :: Showing Error While Compiling Servlet

Jan 23, 2013

I am a beginner want to compile servlet with following path

javac -classpath Program FilesApache Software FoundationTomcat 5.5commonlibservlet-api.jar;classes:.-d classes srccomexamplewebBeerSelect.java

Problem arises as follows:

javac: invalid flag: FilesApache
Usage: javac <options> <source files>
use -help for a list of possible options

View Replies View Related

Getting Error - Cannot Find Symbol When Compiling

Jan 8, 2014

See code.

import java.util.*;
public class CQ1v1{
public static void main(String args []) {
Scanner in = new Scanner (System.in) ;
String name = "";
System.out.println("Welcome to the Interrogator") ;

[Code] ....

When I compile getting

CQ1v1.java:12: error: cannot find symbol
x = in.nextLine ();
^
symbol: variable x
location: class CQ1v1
CQ1v1.java:21: error: cannot find symbol

[Code] ...

View Replies View Related

Constructor Arguments Error When Compiling

Oct 18, 2014

I am trying to create an array where each object includes a service description, price, and time in minutes. I have a Service class and a SalonReport class:

import java.util.*;
public class Service
{
public String serviceDescription;
public double servicePrice;
public int timeMinutes;

[Code] ....

When I compile this, I get an error message that says:

SalonReport.java:8: error: constructor Service in class Service cannot be applied to given types;
salonServices[0] = new Service("Cut", 8.00, 15);
^
required: no arguments
found: String,double,int
reason: actual and formal argument lists differ in length

What this error message means and how I can correct it? I am confused because my SalonService() method has (String service, double price, int minutes), and each object is listed in that exact order.

View Replies View Related

Adding Package Name To Source-code When Compiling / Running From Command Line?

Apr 29, 2015

I am operating java from the command line (using Terminal on Mac OSX 10.9.5).The current directory within Terminal is called "orange" and the following sourcecode file is in the orange directory :

Test1.java
package orange;
public class Test1 {
public static void main(String[] args) {
System.out.println("Test1 works");
}
}

This complies to Test1.class (visible in the orange directory) but when I try to run it in Terminal (simply using "java Test1" from within the orange directory). I get the following error message (which I don't get if I simply comment out the line //package orange;)

Exception in thread "main" java.lang.NoClassDefFoundError: Test1 (wrong name: orange/Test1)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)

[code]...

View Replies View Related

Error When Compiling Rock Paper Scissors

Nov 7, 2014

When I try to compile the code it says " method determineWinner in class RPS cannot be applied to given types;" I think there is something wrong with the way i called the determineWinner method but i'm not what exactly is wrong.

public class RPS
{
public static void main( String [] args )
{
String result;
String userName = getUserName();
String playerChoice, computerChoice;

[code]....

View Replies View Related

Illegal Start Of Expression Error Upon Compiling

Jun 11, 2014

I keep getting this error upon compiling and can't see the problem with it.

The error is on line "45: 15"

/* 37: */ public static EntityDef forID(int i)
/* 38: */ {
/* 39: 10 */ for (int j = 0; j < 20; j++) {
/* 40: 11 */ if (cache[j].type == i) {
/* 41: 12 */ return cache[j];

[Code] .....

View Replies View Related

Run Time Error As Null Pointer Exception While Compiling

Apr 12, 2015

I have an input text file as file.txt where, it consists of only real values separated with commas, and arranged as rows as columns as mentioned below :

1,2,3,4,5,6,10,5,8,9
1,4,7,8,9,0,6,4,3,2,1
2,4,5,8.1.3.4.6.7.9.0

the number of rows is 100 and the number of columns are 9, that is they are fixed.Above is just an example, the file consists of decimal values.What I require is for each column of values I need to find out it's average or mean, that is in above example,

for 1st column:(1+1+2)/3
for 2nd column(2+4+4)/3
for 3rd column(3+7+5)/3,,,,,,,like this till the last column.

So I need to take the input from the .txt file, calculate the column average of each column and the average of each column must be displayed as output. I have done a bit of coding, but it is giving a run-time error as NullPointerException.I will forward my code as attachment, the reading of file, is done as string in java and then it must be converted to double values, also to read the comma separated input from a file I have used the split().

View Replies View Related

Illegal Start Of Expression Error When Compiling Program

Apr 11, 2013

class Test1
     {
     public static void main(String args[])
          {
          void show()
               {
               System.out.print("its working");
               }
          show();
          }
     }

When I compile this program i find the error illegal start of expression

^void show
Test1.java5 ';' is expected

View Replies View Related

Getting Error On Java Code Using Parallel Arrays

Dec 1, 2014

This is my code.

public class PA9 {

public static void main(String[] args) throws FileNotFoundException {
// create data file to read from
File inf = new File("cityPopulationData.txt");
//Create a file to write out to.
PrintWriter fileOut = new PrintWriter("output.txt");

[Code] .....

This is my error

Exception in thread "main" java.util.InputMismatchException
at java.util.Scanner.throwFor(Scanner.java:909)
at java.util.Scanner.next(Scanner.java:1530)
at java.util.Scanner.nextInt(Scanner.java:2160)
at java.util.Scanner.nextInt(Scanner.java:2119)
at PA9.getData(PA9.java:35)
at PA9.main(PA9.java:22)

View Replies View Related

Getting Error With Java Code - Using Parallel Arrays

Dec 1, 2014

Write a Java program to read from the data file, find the city with the highest population based on the 2010 census data, the city with the highest population growth from 2010 to 2013, the city with the lowest population growth from 2010 to 2013, and the city with the highest density (number of persons per sq. mile).

import java.io.File;
import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.util.Scanner;

[code]....

View Replies View Related

Getting Error While Running Code From Head First Java In Eclipse

Jan 2, 2015

I downloaded this code from Head First Java. But when I tried running it on Eclipse, it gives this error message.

import javax.sound.midi.*;
public class MiniMiniMusicApp { // this is the first one
public static void main(String[] args) {
MiniMiniMusicApp mini = new MiniMiniMusicApp();
mini.play();

[code]....

and this was the error message: Jan 02, 2015 8:10:36 PM java.util.prefs.WindowsPreferences <init>Could not open/create prefs root node Software Java SoftPrefs at root 0x80000002. Windows RegCreateKeyEx(...) returned error code 5.

View Replies View Related

Error Connecting To Unix And Running Script From Java Code

Jun 25, 2014

I get the following error when trying to run code.

java.lang.NullPointerException
at conntecttoDB8.SSHCommandExecutor.main(SSHCommandEx ecutor.java:26)

package conntecttoDB8;
import java.io.InputStream;
import com.jcraft.jsch.Channel;
import com.jcraft.jsch.JSch;
import com.jcraft.jsch.Session;
 
[Code] ....

View Replies View Related

Compiling Java Application

Feb 27, 2015

So say I write up a program like a dice roll game, which I see on the forums here. It's all written and good to go and when I hit Run it does what I want it to do, no errors..What do I do with those .class and .java files? Do I compile it somehow into an app I can put on the google play store? What is the NEXT STEP after the program is all written?

View Replies View Related

Access Is Denied While Compiling The Java File

Oct 30, 2014

I am getting an error as follows while trying to compile a java file for servlet:-

"error while writing BeerSelect: WEB-INFclassesBeerSelect.class (Access is denied)
public class BeerSelect extends HttpServlet
^
1 error"

I am using "C:Program FilesApache Software FoundationTomcat 8.0webappsBeerBottlejavac -d WEB-INFclasses BeerSelect.java" to compile the file.

I am using Windows 8.1

View Replies View Related

Compiling Multiple Java File Using Terminal In Ubuntu 12.04

Feb 11, 2015

I am new in java. I executed a java program using eclipse. the program contain two java file. when i try to run it using terminal in Ubuntu. Two files are not linking. it shows error. i am attaching all the data.

It shows the following error

regex2string.java:83: error: cannot find symbol
str = randomstr.nextString(2000);
^
symbol: variable randomstr
location: class regex2string
1 error

[Code] ...

View Replies View Related

JSP :: Eclipse Project Window Shows Error But Code Editor Shows No Error

May 22, 2014

For my jsp file, the code editor shows no error, but the projects window shows an error. I built my project again, cleaned the project, restart eclipse twice and summoned cthulhu. But my project still shows an error. How do I find the cause.

Eclipse project -

JSP file -

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ taglib prefix="mine" uri="DiceFunctions"%>

[Code] ....

View Replies View Related

JSP :: Error Page Is Not Displaying Instead Error Status Code Is Displaying

Apr 5, 2014

I have written some error checking code

File name ErrorPage.jsp

<%@ page language="java" isErrorPage="true" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Error</title>
</head>

[code]...

I have put error.jsp and badpage.jsp file in public access folder that is web content in eclipsewhen I am running the code I am status code of 500 and not the errorpage.jsp message .

View Replies View Related

Code Compiles But Gives Error When Run It

Feb 17, 2014

So I am finishing up a GUI that randomly rolls a dice and shows you the dice face from a file that I have on my computer. It compiles fine, but when I open the GUI and press the button "Roll" it gives me errors and does not display the images.

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.border.*;
import java.util.Random;

[code]....

View Replies View Related

Search Code Error

Jan 14, 2015

I am pretty new to Java and I am working on a sample Search code from my textbook. I can't figure out why I am getting the following error because I copied the sample exactly as it is in the book. The error is illegal start of expression on the second to last line.

public class Search {
public static final int NOT_FOUND = -1;
public static int binarySearch( int [] a, int x )
{
int low = 0;
int high = a.length - 1;
int mid;

[code]....

View Replies View Related

BlueJ Error Code

Apr 6, 2014

the system I am using is blue jay and java. my problem is that I have this error message pop up whenever I try to compile any of my 6 classes. Three of the classes are cities, 3 others are shops, and the final one is a inventory called Player. The following is the error code that appears when I try to compile class THshopB or class CityB.

method run in class CityB cannot be applied to given types;required: Player; found: no arguments; reason: actual and formal argument lists differ in length

A similar error occurs for the rest of my City and THshop classes,except it replaces the class CityB with CityA and occurs in class THshopA, replaces CityB with CityC when occurring in class THshopC.The public methods of CityB and THshopB are shown below, as I believe that something is wrong with the public method of one or the other. I have the code [CItyB.run();}] inside of class THshopB, and run is the part that gets the red highlight error described above.THshopB public method

[ public static void shop(Player inventory){
CityB.run();}]
CityB public method
[ public static void run(Player inventory){
THshopB.shop(inventory);]

All of my THshop classes are written in the same format, and all of my City classes are written in the same format,

View Replies View Related

Syntax Error When Testing Code

Jun 4, 2014

My issue is that when I run the code if I enter anything but 1, 2, or 3 the code breaks. I have spent hours trying to find the error. here is my code

import java.util.Scanner;
public class Tester {
public static void main(String[] args) {
/**
* constructor
* pre: none
* post: inherit values of other classes
*/
Car Car = new Car(); //inherits the properties of the Car class
Truck Truck = new Truck(); //inherits the properties of the Truck class

[code]....

View Replies View Related

Error And Dead Code Warning

Mar 26, 2015

There are 2 methods and a main one. The first is a void that creates a 3x4 2d array and the second is to search for a value in the array, if found it will return the number of the row that contains that value. If not, it will return -1, but I am getting 1 error and 1 dead code warning.I will put comments at the lines that contain the problems

import java.util.Scanner;
class Question4{
public static void main(String[]args){
Scanner s = new Scanner(System.in);
int x,n;
System.out.println("Please input the value that will be used in the array");
x=s.nextInt();
System.out.println("What is the value you want to search for?");
n=s.nextInt();
createArray (x,n);

[code]....

View Replies View Related

Access Restriction Error In Decryption Code

May 21, 2015

I am getting error message on Java code that was developed by someone else and is supposed to work.

public String decrypt(String password) {
try {
// create the key and parameter spec
KeySpec keySpec = new PBEKeySpec(password.toCharArray(), salt, interactions);
SecretKey key = SecretKeyFactory.getInstance(keyFormat).generateSecret(keySpec);
AlgorithmParameterSpec paramSpec = new PBEParameterSpec(salt, interactions);
// create the cipher

[code]...

the error message is as follows: Access restriction: The type 'BASE64Decoder" is not API (restriction on required library '/usr/lib64/jvm/java-1.8.0-openjdk-1.8.0/jre/lib/rd.jar')I am using eclipse.

View Replies View Related

Error In Code While Changing String To Int Array

Mar 7, 2015

import java.io.InputStreamReader;
import java.util.Scanner;
public class FinalCombinations {
public static void main(String[] args){
//Read number of values
System.out.println("Enter the no of values");

[Code] .....

I am getting output like this

Enter the no of values
4

Enter the values
1
2
3
4

Enter the number for combination
2
C(4,2)=6
1
1
2
1
1
3
1
1
4
2
2
3
2
2
4
3
3
4

where as I want output like this..wit one array
1
2
1
3
1
4
2
3
2
4
3
4

View Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved