Ask coding questions

← Back to all posts
Boolean Parenthesization problem using memoisation
h
SaunakNandi (1)

Problem statement- ( https://www.geeksforgeeks.org/boolean-parenthesization-problem-dp-37/ )
I am unable to solve the problem using Map in java can Anyone kindly help me to do this

Comments
hotnewtop
SaunakNandi (1)

I am new to Map so plz make it easy for understanding

CodeMaster007 (108)

Hey! Check this out... @SaunakNandi

geeksforgeeks.org/boolean-parenthesization-problem-dp-37/

SaunakNandi (1)

@CodeMaster007 Bro I told that I want to solve it using Map not using 3D matrix

SaunakNandi (1)

@CodeMaster007 U are giving back the same link I mentioned

CodeMaster007 (108)

Oh. My bad. I didn't see that there. @SaunakNandi

SaunakNandi (1)

@CodeMaster007 okk no problem . SO, where are u from

SaunakNandi (1)

@CodeMaster007 I have read this . I just want a fix for my program

CodeMaster007 (108)

Hey! @SaunakNandi So I read some about this and found a article on how to fix your problem. Here it is....

javarevisited.blogspot.com/2011/08/classnotfoundexception-in-java-example.html#axzz6shjmLrnL

The article is pretty long and I found the part which you need so here it is below.
Thanks,

CodeMaster007


1) First find out the jar file on which problematic class file is present for example in case of "com.mysql.jdbc.driver" its mysql-connector-java.jar. If you don't know how to find which jar file a particular class you can see eclipse shortcuts to do that or you can simply do "Ctrl+T" in Eclipse and type the name of class, It will list all the jar in the order they appear in eclipse classpath.

2) Check whether your classpath contains that jar, if your classpath doesn't contain the jar then just add that class in your classpath.
3) If it’s present in your classpath then there is high chance that your classpath is getting overridden or application is using classpath specified in jar file or start-up script and to fix that you need to find the exact classpath used by your application.

Live example of reproducing and Fixing ClassNotFoundException in java
I think if we are able to reproduce and solve certain problem we become more comfortable dealing with that, that’s why here we will reproduce java.lang.ClassNotFoundException and solve it by following the concept we have discussed so far.

1) Create a Class called StockTrading.java

public class StockTrading{
public String getDescription(){
return "StockTrading";
}
}

2) create a Class called OnlineStockTranding.java and load the class StockTrading.java as Class.forName ("stocktrading");

public class OnlineStockTrading {
public static void main(String args[]) throws ClassNotFoundException{
Class.forName("StockTrading");
System.out.println("StockTrading class successfully loaded");
}
}

3) Compile both Java source file which will create two class files and run the program should run fine.

[email protected]~/java: javac *.java

[email protected] ~/java: ls –lrt
-rw-r--r-- 1 javin None 90 Aug 21 09:27 StockTrading.java
-rw-r--r-- 1 javin None 208 Aug 21 09:28 OnlineStockTrading.java
-rwxr-xr-x 1 javin None 282 Aug 21 09:28 StockTrading.class
-rwxr-xr-x 1 javin None 638 Aug 21 09:28 OnlineStockTrading.class

[email protected] ~/java:$ java OnlineStockTrading
StockTrading class successfully loaded

4) Now just remove the .class file for stocktrading.java and run the Java program and it will throw java.lang.ClassNotFoundException in java.

[email protected] ~/java: rm StockTrading.class

[email protected] ~/java: java OnlineStockTrading
Exception in thread "main" java.lang.ClassNotFoundException: StockTrading
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)